Permalink
Browse files

stubs: move LoadVarArg to stub

  • Loading branch information...
1 parent ac07d23 commit a8578e60a738509ec330c375f420b8684d29fae1 @indutny committed Nov 16, 2012
View
@@ -7,8 +7,8 @@
'osx_arch%': ''
},
'conditions': [
- ['OS == "mac" and osx_arch != "ia32"', {
- 'target_arch%': 'x64'
+ ['OS == "mac" and osx_arch == "ia32"', {
+ 'target_arch%': 'ia32'
}, {
'target_arch%': '<(host_arch)'
}]
@@ -24,7 +24,7 @@
'GCC_VERSION': '4.1',
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
'PREBINDING': 'NO', # No -Wl,-prebind
- 'MACOSX_DEPLOYMENT_TARGET': '10.6', # -mmacosx-version-min=10.6
+ 'MACOSX_DEPLOYMENT_TARGET': '10.6', # -mmacosx-version-min=10.5
'USE_HEADERMAP': 'NO',
'WARNING_CFLAGS': [
'-Wall',
View
@@ -454,7 +454,7 @@ void FLoadVarArg::Generate(Masm* masm) {
__ mov(eax, *inputs[0]->ToOperand());
__ mov(ebx, *inputs[1]->ToOperand());
__ mov(ecx, *inputs[2]->ToOperand());
- __ LoadVarArg();
+ __ Call(masm->stubs()->GetLoadVarArgStub());
}
View
@@ -440,7 +440,7 @@ void LLoadArg::Generate(Masm* masm) {
void LLoadVarArg::Generate(Masm* masm) {
- __ LoadVarArg();
+ __ Call(masm->stubs()->GetLoadVarArgStub());
}
@@ -133,6 +133,13 @@ void Masm::Spill::Unspill() {
}
+Operand* Masm::Spill::GetOperand() {
+ Operand* r = new Operand(eax, 0);
+ masm()->SpillSlot(index(), *r);
+ return r;
+}
+
+
void Masm::AllocateSpills() {
subl(esp, Immediate(0));
spill_reloc_ = new RelocationInfo(RelocationInfo::kValue,
@@ -738,6 +745,7 @@ void Masm::StoreVarArg() {
jmp(&loop);
+ // }
bind(&odd_end);
r1.Unspill(eax);
@@ -749,99 +757,6 @@ void Masm::StoreVarArg() {
}
-void Masm::LoadVarArg() {
- // offset and rest are unboxed
- Register offset = eax;
- Register rest = ebx;
- Register arr = ecx;
- Operand argc(ebp, -HValue::kPointerSize * 2);
- Operand qmap(arr, HObject::kMapOffset);
- Operand slot(scratch, 0);
- Operand stack_slot(offset, 0);
-
- Label loop, preloop, end;
-
- // Calculate length of vararg array
- mov(scratch, offset);
- addl(scratch, rest);
-
- // If offset + rest <= argc - return immediately
- cmpl(scratch, argc);
- jmp(kGe, &end);
-
- // edx = argc - offset - rest
- mov(edx, argc);
- subl(edx, scratch);
-
- // Array index
- mov(ebx, Immediate(HNumber::Tag(0)));
-
- Spill arr_s(this, arr), edx_s(this);
- Spill offset_s(this, offset), ebx_s(this);
-
- bind(&loop);
-
- // while (edx > 0)
- cmpl(edx, Immediate(HNumber::Tag(0)));
- jmp(kEq, &end);
-
- edx_s.SpillReg(edx);
- ebx_s.SpillReg(ebx);
-
- mov(eax, arr);
-
- // eax <- object
- // ebx <- property
- mov(ecx, Immediate(1));
- Call(stubs()->GetLookupPropertyStub());
-
- arr_s.Unspill();
- ebx_s.Unspill();
-
- // Make eax look like unboxed number to GC
- dec(eax);
- CheckGC();
- inc(eax);
-
- IsNil(eax, NULL, &preloop);
-
- mov(arr, qmap);
- addl(eax, arr);
- mov(scratch, eax);
-
- // Get stack offset
- offset_s.Unspill();
- addlb(offset, Immediate(HNumber::Tag(2)));
- addl(offset, ebx);
- shl(offset, 1);
- addl(offset, ebp);
- mov(offset, stack_slot);
-
- // Put argument in array
- mov(slot, offset);
-
- arr_s.Unspill();
-
- bind(&preloop);
-
- // Increment array index
- addlb(ebx, Immediate(HNumber::Tag(1)));
-
- // edx --
- edx_s.Unspill();
- sublb(edx, Immediate(HNumber::Tag(1)));
- jmp(&loop);
-
- bind(&end);
-
- // Cleanup?
- xorl(eax, eax);
- xorl(ebx, ebx);
- xorl(edx, edx);
- // ecx <- holds result
-}
-
-
void Masm::ProbeCPU() {
push(ebp);
mov(ebp, esp);
View
@@ -1195,5 +1195,103 @@ void BinOpStub::Generate() {
#undef BINARY_SUB_TYPES
+void LoadVarArgStub::Generate() {
+ __ mov(edx, ebp);
+ GeneratePrologue();
+
+ // offset and rest are unboxed
+ Register offset = eax;
+ Register rest = ebx;
+ Register arr = ecx;
+ Masm::Spill ebp_s(masm(), edx);
+ Operand argc(edx, -HValue::kPointerSize * 2);
+ Operand qmap(arr, HObject::kMapOffset);
+ Operand slot(scratch, 0);
+ Operand stack_slot(offset, 0);
+
+ Label loop, preloop, end;
+
+ // Calculate length of vararg array
+ __ mov(scratch, offset);
+ __ addl(scratch, rest);
+
+ // If offset + rest <= argc - return immediately
+ __ cmpl(scratch, argc);
+ __ jmp(kGe, &end);
+
+ // edx = argc - offset - rest
+ __ mov(edx, argc);
+ __ subl(edx, scratch);
+
+ // Array index
+ __ mov(ebx, Immediate(HNumber::Tag(0)));
+
+ Masm::Spill arr_s(masm(), arr), edx_s(masm());
+ Masm::Spill offset_s(masm(), offset), ebx_s(masm());
+
+ __ bind(&loop);
+
+ // while (edx > 0)
+ __ cmpl(edx, Immediate(HNumber::Tag(0)));
+ __ jmp(kEq, &end);
+
+ edx_s.SpillReg(edx);
+ ebx_s.SpillReg(ebx);
+
+ __ mov(eax, arr);
+
+ // eax <- object
+ // ebx <- property
+ __ mov(ecx, Immediate(1));
+ __ Call(masm()->stubs()->GetLookupPropertyStub());
+
+ arr_s.Unspill();
+ ebx_s.Unspill();
+
+ // Make eax look like unboxed number to GC
+ __ dec(eax);
+ __ CheckGC();
+ __ inc(eax);
+
+ __ IsNil(eax, NULL, &preloop);
+
+ __ mov(arr, qmap);
+ __ addl(eax, arr);
+ __ mov(scratch, eax);
+
+ // Get stack offset
+ offset_s.Unspill();
+ __ addlb(offset, Immediate(HNumber::Tag(2)));
+ __ addl(offset, ebx);
+ __ shl(offset, 1);
+ __ addl(offset, *ebp_s.GetOperand());
+ __ mov(offset, stack_slot);
+
+ // Put argument in array
+ __ mov(slot, offset);
+
+ arr_s.Unspill();
+
+ __ bind(&preloop);
+
+ // Increment array index
+ __ addlb(ebx, Immediate(HNumber::Tag(1)));
+
+ // edx --
+ edx_s.Unspill();
+ __ sublb(edx, Immediate(HNumber::Tag(1)));
+ __ jmp(&loop);
+
+ __ bind(&end);
+
+ // Cleanup?
+ __ xorl(eax, eax);
+ __ xorl(ebx, ebx);
+ __ xorl(edx, edx);
+ // ecx <- holds result
+
+ GenerateEpilogue();
+}
+
} // namespace internal
} // namespace candor
View
@@ -42,6 +42,7 @@ class Masm : public Assembler {
void Unspill(Register dst);
void Unspill();
+ Operand* GetOperand();
inline bool is_empty() { return src_.is(reg_nil); }
@@ -92,7 +93,6 @@ class Masm : public Assembler {
// Varargs
void StoreVarArg();
- void LoadVarArg();
// Generate enter/exit frame sequences
void EnterFramePrologue();
View
@@ -31,7 +31,8 @@ namespace internal {
V(CloneObject)\
V(DeleteProperty)\
V(HashValue)\
- V(StackTrace)
+ V(StackTrace)\
+ V(LoadVarArg)
#define BINARY_STUBS_LIST(V)\
V(Add)\
View
@@ -425,7 +425,7 @@ void FLoadVarArg::Generate(Masm* masm) {
__ mov(rax, *inputs[0]->ToOperand());
__ mov(rbx, *inputs[1]->ToOperand());
__ mov(rcx, *inputs[2]->ToOperand());
- __ LoadVarArg();
+ __ Call(masm->stubs()->GetLoadVarArgStub());
}
View
@@ -419,7 +419,7 @@ void LLoadArg::Generate(Masm* masm) {
void LLoadVarArg::Generate(Masm* masm) {
- __ LoadVarArg();
+ __ Call(masm->stubs()->GetLoadVarArgStub());
}
Oops, something went wrong.

0 comments on commit a8578e6

Please sign in to comment.