Skip to content
This repository
Browse code

stubs: move LoadVarArg to stub

  • Loading branch information...
commit a8578e60a738509ec330c375f420b8684d29fae1 1 parent ac07d23
Fedor Indutny authored November 16, 2012
6  common.gypi
@@ -7,8 +7,8 @@
7 7
       'osx_arch%': ''
8 8
     },
9 9
     'conditions': [
10  
-      ['OS == "mac" and osx_arch != "ia32"', {
11  
-        'target_arch%': 'x64'
  10
+      ['OS == "mac" and osx_arch == "ia32"', {
  11
+        'target_arch%': 'ia32'
12 12
       }, {
13 13
         'target_arch%': '<(host_arch)'
14 14
       }]
@@ -24,7 +24,7 @@
24 24
           'GCC_VERSION': '4.1',
25 25
           'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES',  # -Wnewline-eof
26 26
           'PREBINDING': 'NO',                       # No -Wl,-prebind
27  
-          'MACOSX_DEPLOYMENT_TARGET': '10.6',       # -mmacosx-version-min=10.6
  27
+          'MACOSX_DEPLOYMENT_TARGET': '10.6',       # -mmacosx-version-min=10.5
28 28
           'USE_HEADERMAP': 'NO',
29 29
           'WARNING_CFLAGS': [
30 30
             '-Wall',
2  src/ia32/fullgen-ia32.cc
@@ -454,7 +454,7 @@ void FLoadVarArg::Generate(Masm* masm) {
454 454
   __ mov(eax, *inputs[0]->ToOperand());
455 455
   __ mov(ebx, *inputs[1]->ToOperand());
456 456
   __ mov(ecx, *inputs[2]->ToOperand());
457  
-  __ LoadVarArg();
  457
+  __ Call(masm->stubs()->GetLoadVarArgStub());
458 458
 }
459 459
 
460 460
 
2  src/ia32/lir-ia32.cc
@@ -440,7 +440,7 @@ void LLoadArg::Generate(Masm* masm) {
440 440
 
441 441
 
442 442
 void LLoadVarArg::Generate(Masm* masm) {
443  
-  __ LoadVarArg();
  443
+  __ Call(masm->stubs()->GetLoadVarArgStub());
444 444
 }
445 445
 
446 446
 
101  src/ia32/macroassembler-ia32.cc
@@ -133,6 +133,13 @@ void Masm::Spill::Unspill() {
133 133
 }
134 134
 
135 135
 
  136
+Operand* Masm::Spill::GetOperand() {
  137
+  Operand* r = new Operand(eax, 0);
  138
+  masm()->SpillSlot(index(), *r);
  139
+  return r;
  140
+}
  141
+
  142
+
136 143
 void Masm::AllocateSpills() {
137 144
   subl(esp, Immediate(0));
138 145
   spill_reloc_ = new RelocationInfo(RelocationInfo::kValue,
@@ -738,6 +745,7 @@ void Masm::StoreVarArg() {
738 745
 
739 746
   jmp(&loop);
740 747
 
  748
+  // }
741 749
   bind(&odd_end);
742 750
 
743 751
   r1.Unspill(eax);
@@ -749,99 +757,6 @@ void Masm::StoreVarArg() {
749 757
 }
750 758
 
751 759
 
752  
-void Masm::LoadVarArg() {
753  
-  // offset and rest are unboxed
754  
-  Register offset = eax;
755  
-  Register rest = ebx;
756  
-  Register arr = ecx;
757  
-  Operand argc(ebp, -HValue::kPointerSize * 2);
758  
-  Operand qmap(arr, HObject::kMapOffset);
759  
-  Operand slot(scratch, 0);
760  
-  Operand stack_slot(offset, 0);
761  
-
762  
-  Label loop, preloop, end;
763  
-
764  
-  // Calculate length of vararg array
765  
-  mov(scratch, offset);
766  
-  addl(scratch, rest);
767  
-
768  
-  // If offset + rest <= argc - return immediately
769  
-  cmpl(scratch, argc);
770  
-  jmp(kGe, &end);
771  
-
772  
-  // edx = argc - offset - rest
773  
-  mov(edx, argc);
774  
-  subl(edx, scratch);
775  
-
776  
-  // Array index
777  
-  mov(ebx, Immediate(HNumber::Tag(0)));
778  
-
779  
-  Spill arr_s(this, arr), edx_s(this);
780  
-  Spill offset_s(this, offset), ebx_s(this);
781  
-
782  
-  bind(&loop);
783  
-
784  
-  // while (edx > 0)
785  
-  cmpl(edx, Immediate(HNumber::Tag(0)));
786  
-  jmp(kEq, &end);
787  
-
788  
-  edx_s.SpillReg(edx);
789  
-  ebx_s.SpillReg(ebx);
790  
-
791  
-  mov(eax, arr);
792  
-
793  
-  // eax <- object
794  
-  // ebx <- property
795  
-  mov(ecx, Immediate(1));
796  
-  Call(stubs()->GetLookupPropertyStub());
797  
-
798  
-  arr_s.Unspill();
799  
-  ebx_s.Unspill();
800  
-
801  
-  // Make eax look like unboxed number to GC
802  
-  dec(eax);
803  
-  CheckGC();
804  
-  inc(eax);
805  
-
806  
-  IsNil(eax, NULL, &preloop);
807  
-
808  
-  mov(arr, qmap);
809  
-  addl(eax, arr);
810  
-  mov(scratch, eax);
811  
-
812  
-  // Get stack offset
813  
-  offset_s.Unspill();
814  
-  addlb(offset, Immediate(HNumber::Tag(2)));
815  
-  addl(offset, ebx);
816  
-  shl(offset, 1);
817  
-  addl(offset, ebp);
818  
-  mov(offset, stack_slot);
819  
-
820  
-  // Put argument in array
821  
-  mov(slot, offset);
822  
-
823  
-  arr_s.Unspill();
824  
-
825  
-  bind(&preloop);
826  
-
827  
-  // Increment array index
828  
-  addlb(ebx, Immediate(HNumber::Tag(1)));
829  
-
830  
-  // edx --
831  
-  edx_s.Unspill();
832  
-  sublb(edx, Immediate(HNumber::Tag(1)));
833  
-  jmp(&loop);
834  
-
835  
-  bind(&end);
836  
-
837  
-  // Cleanup?
838  
-  xorl(eax, eax);
839  
-  xorl(ebx, ebx);
840  
-  xorl(edx, edx);
841  
-  // ecx <- holds result
842  
-}
843  
-
844  
-
845 760
 void Masm::ProbeCPU() {
846 761
   push(ebp);
847 762
   mov(ebp, esp);
98  src/ia32/stubs-ia32.cc
@@ -1195,5 +1195,103 @@ void BinOpStub::Generate() {
1195 1195
 
1196 1196
 #undef BINARY_SUB_TYPES
1197 1197
 
  1198
+void LoadVarArgStub::Generate() {
  1199
+  __ mov(edx, ebp);
  1200
+  GeneratePrologue();
  1201
+
  1202
+  // offset and rest are unboxed
  1203
+  Register offset = eax;
  1204
+  Register rest = ebx;
  1205
+  Register arr = ecx;
  1206
+  Masm::Spill ebp_s(masm(), edx);
  1207
+  Operand argc(edx, -HValue::kPointerSize * 2);
  1208
+  Operand qmap(arr, HObject::kMapOffset);
  1209
+  Operand slot(scratch, 0);
  1210
+  Operand stack_slot(offset, 0);
  1211
+
  1212
+  Label loop, preloop, end;
  1213
+
  1214
+  // Calculate length of vararg array
  1215
+  __ mov(scratch, offset);
  1216
+  __ addl(scratch, rest);
  1217
+
  1218
+  // If offset + rest <= argc - return immediately
  1219
+  __ cmpl(scratch, argc);
  1220
+  __ jmp(kGe, &end);
  1221
+
  1222
+  // edx = argc - offset - rest
  1223
+  __ mov(edx, argc);
  1224
+  __ subl(edx, scratch);
  1225
+
  1226
+  // Array index
  1227
+  __ mov(ebx, Immediate(HNumber::Tag(0)));
  1228
+
  1229
+  Masm::Spill arr_s(masm(), arr), edx_s(masm());
  1230
+  Masm::Spill offset_s(masm(), offset), ebx_s(masm());
  1231
+
  1232
+  __ bind(&loop);
  1233
+
  1234
+  // while (edx > 0)
  1235
+  __ cmpl(edx, Immediate(HNumber::Tag(0)));
  1236
+  __ jmp(kEq, &end);
  1237
+
  1238
+  edx_s.SpillReg(edx);
  1239
+  ebx_s.SpillReg(ebx);
  1240
+
  1241
+  __ mov(eax, arr);
  1242
+
  1243
+  // eax <- object
  1244
+  // ebx <- property
  1245
+  __ mov(ecx, Immediate(1));
  1246
+  __ Call(masm()->stubs()->GetLookupPropertyStub());
  1247
+
  1248
+  arr_s.Unspill();
  1249
+  ebx_s.Unspill();
  1250
+
  1251
+  // Make eax look like unboxed number to GC
  1252
+  __ dec(eax);
  1253
+  __ CheckGC();
  1254
+  __ inc(eax);
  1255
+
  1256
+  __ IsNil(eax, NULL, &preloop);
  1257
+
  1258
+  __ mov(arr, qmap);
  1259
+  __ addl(eax, arr);
  1260
+  __ mov(scratch, eax);
  1261
+
  1262
+  // Get stack offset
  1263
+  offset_s.Unspill();
  1264
+  __ addlb(offset, Immediate(HNumber::Tag(2)));
  1265
+  __ addl(offset, ebx);
  1266
+  __ shl(offset, 1);
  1267
+  __ addl(offset, *ebp_s.GetOperand());
  1268
+  __ mov(offset, stack_slot);
  1269
+
  1270
+  // Put argument in array
  1271
+  __ mov(slot, offset);
  1272
+
  1273
+  arr_s.Unspill();
  1274
+
  1275
+  __ bind(&preloop);
  1276
+
  1277
+  // Increment array index
  1278
+  __ addlb(ebx, Immediate(HNumber::Tag(1)));
  1279
+
  1280
+  // edx --
  1281
+  edx_s.Unspill();
  1282
+  __ sublb(edx, Immediate(HNumber::Tag(1)));
  1283
+  __ jmp(&loop);
  1284
+
  1285
+  __ bind(&end);
  1286
+
  1287
+  // Cleanup?
  1288
+  __ xorl(eax, eax);
  1289
+  __ xorl(ebx, ebx);
  1290
+  __ xorl(edx, edx);
  1291
+  // ecx <- holds result
  1292
+
  1293
+  GenerateEpilogue();
  1294
+}
  1295
+
1198 1296
 } // namespace internal
1199 1297
 } // namespace candor
2  src/macroassembler.h
@@ -42,6 +42,7 @@ class Masm : public Assembler {
42 42
 
43 43
     void Unspill(Register dst);
44 44
     void Unspill();
  45
+    Operand* GetOperand();
45 46
 
46 47
     inline bool is_empty() { return src_.is(reg_nil); }
47 48
 
@@ -92,7 +93,6 @@ class Masm : public Assembler {
92 93
 
93 94
   // Varargs
94 95
   void StoreVarArg();
95  
-  void LoadVarArg();
96 96
 
97 97
   // Generate enter/exit frame sequences
98 98
   void EnterFramePrologue();
3  src/stubs.h
@@ -31,7 +31,8 @@ namespace internal {
31 31
     V(CloneObject)\
32 32
     V(DeleteProperty)\
33 33
     V(HashValue)\
34  
-    V(StackTrace)
  34
+    V(StackTrace)\
  35
+    V(LoadVarArg)
35 36
 
36 37
 #define BINARY_STUBS_LIST(V)\
37 38
     V(Add)\
2  src/x64/fullgen-x64.cc
@@ -425,7 +425,7 @@ void FLoadVarArg::Generate(Masm* masm) {
425 425
   __ mov(rax, *inputs[0]->ToOperand());
426 426
   __ mov(rbx, *inputs[1]->ToOperand());
427 427
   __ mov(rcx, *inputs[2]->ToOperand());
428  
-  __ LoadVarArg();
  428
+  __ Call(masm->stubs()->GetLoadVarArgStub());
429 429
 }
430 430
 
431 431
 
2  src/x64/lir-x64.cc
@@ -419,7 +419,7 @@ void LLoadArg::Generate(Masm* masm) {
419 419
 
420 420
 
421 421
 void LLoadVarArg::Generate(Masm* masm) {
422  
-  __ LoadVarArg();
  422
+  __ Call(masm->stubs()->GetLoadVarArgStub());
423 423
 }
424 424
 
425 425
 
100  src/x64/macroassembler-x64.cc
@@ -130,6 +130,13 @@ void Masm::Spill::Unspill() {
130 130
 }
131 131
 
132 132
 
  133
+Operand* Masm::Spill::GetOperand() {
  134
+  Operand* r = new Operand(rax, 0);
  135
+  masm()->SpillSlot(index(), *r);
  136
+  return r;
  137
+}
  138
+
  139
+
133 140
 void Masm::AllocateSpills() {
134 141
   subq(rsp, Immediate(0));
135 142
   spill_reloc_ = new RelocationInfo(RelocationInfo::kValue,
@@ -723,99 +730,6 @@ void Masm::StoreVarArg() {
723 730
 }
724 731
 
725 732
 
726  
-void Masm::LoadVarArg() {
727  
-  // offset and rest are unboxed
728  
-  Register offset = rax;
729  
-  Register rest = rbx;
730  
-  Register arr = rcx;
731  
-  Operand argc(rbp, -HValue::kPointerSize * 2);
732  
-  Operand qmap(arr, HObject::kMapOffset);
733  
-  Operand slot(scratch, 0);
734  
-  Operand stack_slot(offset, 0);
735  
-
736  
-  Label loop, preloop, end;
737  
-
738  
-  // Calculate length of vararg array
739  
-  mov(scratch, offset);
740  
-  addq(scratch, rest);
741  
-
742  
-  // If offset + rest <= argc - return immediately
743  
-  cmpq(scratch, argc);
744  
-  jmp(kGe, &end);
745  
-
746  
-  // rdx = argc - offset - rest
747  
-  mov(rdx, argc);
748  
-  subq(rdx, scratch);
749  
-
750  
-  // Array index
751  
-  mov(rbx, Immediate(HNumber::Tag(0)));
752  
-
753  
-  Spill arr_s(this, arr), rdx_s(this);
754  
-  Spill offset_s(this, offset), rbx_s(this);
755  
-
756  
-  bind(&loop);
757  
-
758  
-  // while (rdx > 0)
759  
-  cmpq(rdx, Immediate(HNumber::Tag(0)));
760  
-  jmp(kEq, &end);
761  
-
762  
-  rdx_s.SpillReg(rdx);
763  
-  rbx_s.SpillReg(rbx);
764  
-
765  
-  mov(rax, arr);
766  
-
767  
-  // rax <- object
768  
-  // rbx <- property
769  
-  mov(rcx, Immediate(1));
770  
-  Call(stubs()->GetLookupPropertyStub());
771  
-
772  
-  arr_s.Unspill();
773  
-  rbx_s.Unspill();
774  
-
775  
-  // Make rax look like unboxed number to GC
776  
-  dec(rax);
777  
-  CheckGC();
778  
-  inc(rax);
779  
-
780  
-  IsNil(rax, NULL, &preloop);
781  
-
782  
-  mov(arr, qmap);
783  
-  addq(rax, arr);
784  
-  mov(scratch, rax);
785  
-
786  
-  // Get stack offset
787  
-  offset_s.Unspill();
788  
-  addqb(offset, Immediate(HNumber::Tag(2)));
789  
-  addq(offset, rbx);
790  
-  shl(offset, 2);
791  
-  addq(offset, rbp);
792  
-  mov(offset, stack_slot);
793  
-
794  
-  // Put argument in array
795  
-  mov(slot, offset);
796  
-
797  
-  arr_s.Unspill();
798  
-
799  
-  bind(&preloop);
800  
-
801  
-  // Increment array index
802  
-  addqb(rbx, Immediate(HNumber::Tag(1)));
803  
-
804  
-  // rdx --
805  
-  rdx_s.Unspill();
806  
-  subqb(rdx, Immediate(HNumber::Tag(1)));
807  
-  jmp(&loop);
808  
-
809  
-  bind(&end);
810  
-
811  
-  // Cleanup?
812  
-  xorq(rax, rax);
813  
-  xorq(rbx, rbx);
814  
-  xorq(rdx, rdx);
815  
-  // rcx <- holds result
816  
-}
817  
-
818  
-
819 733
 void Masm::ProbeCPU() {
820 734
   push(rbp);
821 735
   mov(rbp, rsp);
99  src/x64/stubs-x64.cc
@@ -1107,5 +1107,104 @@ void BinOpStub::Generate() {
1107 1107
 
1108 1108
 #undef BINARY_SUB_TYPES
1109 1109
 
  1110
+
  1111
+void LoadVarArgStub::Generate() {
  1112
+  __ mov(rdx, rbp);
  1113
+  GeneratePrologue();
  1114
+
  1115
+  // offset and rest are unboxed
  1116
+  Register offset = rax;
  1117
+  Register rest = rbx;
  1118
+  Register arr = rcx;
  1119
+  Masm::Spill rbp_s(masm(), rdx);
  1120
+  Operand argc(rdx, -HValue::kPointerSize * 2);
  1121
+  Operand qmap(arr, HObject::kMapOffset);
  1122
+  Operand slot(scratch, 0);
  1123
+  Operand stack_slot(offset, 0);
  1124
+
  1125
+  Label loop, preloop, end;
  1126
+
  1127
+  // Calculate length of vararg array
  1128
+  __ mov(scratch, offset);
  1129
+  __ addq(scratch, rest);
  1130
+
  1131
+  // If offset + rest <= argc - return immediately
  1132
+  __ cmpq(scratch, argc);
  1133
+  __ jmp(kGe, &end);
  1134
+
  1135
+  // rdx = argc - offset - rest
  1136
+  __ mov(rdx, argc);
  1137
+  __ subq(rdx, scratch);
  1138
+
  1139
+  // Array index
  1140
+  __ mov(rbx, Immediate(HNumber::Tag(0)));
  1141
+
  1142
+  Masm::Spill arr_s(masm(), arr), rdx_s(masm());
  1143
+  Masm::Spill offset_s(masm(), offset), rbx_s(masm());
  1144
+
  1145
+  __ bind(&loop);
  1146
+
  1147
+  // while (rdx > 0)
  1148
+  __ cmpq(rdx, Immediate(HNumber::Tag(0)));
  1149
+  __ jmp(kEq, &end);
  1150
+
  1151
+  rdx_s.SpillReg(rdx);
  1152
+  rbx_s.SpillReg(rbx);
  1153
+
  1154
+  __ mov(rax, arr);
  1155
+
  1156
+  // rax <- object
  1157
+  // rbx <- property
  1158
+  __ mov(rcx, Immediate(1));
  1159
+  __ Call(masm()->stubs()->GetLookupPropertyStub());
  1160
+
  1161
+  arr_s.Unspill();
  1162
+  rbx_s.Unspill();
  1163
+
  1164
+  // Make rax look like unboxed number to GC
  1165
+  __ dec(rax);
  1166
+  __ CheckGC();
  1167
+  __ inc(rax);
  1168
+
  1169
+  __ IsNil(rax, NULL, &preloop);
  1170
+
  1171
+  __ mov(arr, qmap);
  1172
+  __ addq(rax, arr);
  1173
+  __ mov(scratch, rax);
  1174
+
  1175
+  // Get stack offset
  1176
+  offset_s.Unspill();
  1177
+  __ addqb(offset, Immediate(HNumber::Tag(2)));
  1178
+  __ addq(offset, rbx);
  1179
+  __ shl(offset, 2);
  1180
+  __ addq(offset, *rbp_s.GetOperand());
  1181
+  __ mov(offset, stack_slot);
  1182
+
  1183
+  // Put argument in array
  1184
+  __ mov(slot, offset);
  1185
+
  1186
+  arr_s.Unspill();
  1187
+
  1188
+  __ bind(&preloop);
  1189
+
  1190
+  // Increment array index
  1191
+  __ addqb(rbx, Immediate(HNumber::Tag(1)));
  1192
+
  1193
+  // rdx --
  1194
+  rdx_s.Unspill();
  1195
+  __ subqb(rdx, Immediate(HNumber::Tag(1)));
  1196
+  __ jmp(&loop);
  1197
+
  1198
+  __ bind(&end);
  1199
+
  1200
+  // Cleanup?
  1201
+  __ xorq(rax, rax);
  1202
+  __ xorq(rbx, rbx);
  1203
+  __ xorq(rdx, rdx);
  1204
+  // rcx <- holds result
  1205
+
  1206
+  GenerateEpilogue(0);
  1207
+}
  1208
+
1110 1209
 } // namespace internal
1111 1210
 } // namespace candor

0 notes on commit a8578e6

Please sign in to comment.
Something went wrong with that request. Please try again.