Index: src/x64/ic-x64.cc |
=================================================================== |
--- src/x64/ic-x64.cc (revision 2244) |
+++ src/x64/ic-x64.cc (working copy) |
@@ -54,11 +54,29 @@ |
UNIMPLEMENTED(); |
} |
+ |
void KeyedLoadIC::Generate(MacroAssembler* masm, |
ExternalReference const& f) { |
- masm->int3(); // UNIMPLEMENTED. |
+ // ----------- S t a t e ------------- |
+ // -- rsp[0] : return address |
+ // -- rsp[8] : name |
+ // -- rsp[16] : receiver |
+ // ----------------------------------- |
+ |
+ __ movq(rax, Operand(rsp, kPointerSize)); |
+ __ movq(rcx, Operand(rsp, 2 * kPointerSize)); |
+ |
+ // Move the return address below the arguments. |
+ __ pop(rbx); |
+ __ push(rcx); |
+ __ push(rax); |
+ __ push(rbx); |
+ |
+ // Perform tail call to the entry. |
+ __ TailCallRuntime(f, 2); |
} |
+ |
void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { |
masm->int3(); // UNIMPLEMENTED. |
} |
@@ -124,7 +142,22 @@ |
} |
void KeyedStoreIC::Generate(MacroAssembler* masm, ExternalReference const& f) { |
- masm->int3(); // UNIMPLEMENTED. |
+ // ----------- S t a t e ------------- |
+ // -- rax : value |
+ // -- rsp[0] : return address |
+ // -- rsp[8] : key |
+ // -- rsp[16] : receiver |
+ // ----------------------------------- |
+ |
+ // Move the return address below the arguments. |
+ __ pop(rcx); |
+ __ push(Operand(rsp, 1 * kPointerSize)); |
+ __ push(Operand(rsp, 1 * kPointerSize)); |
+ __ push(rax); |
+ __ push(rcx); |
+ |
+ // Do tail-call to runtime routine. |
+ __ TailCallRuntime(f, 3); |
} |
void KeyedStoreIC::GenerateExtendStorage(MacroAssembler* masm) { |
@@ -143,14 +176,93 @@ |
return NULL; |
} |
+ |
+void CallIC::Generate(MacroAssembler* masm, |
+ int argc, |
+ ExternalReference const& f) { |
+ // Get the receiver of the function from the stack; 1 ~ return address. |
+ __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
+ // Get the name of the function to call from the stack. |
+ // 2 ~ receiver, return address. |
+ __ movq(rbx, Operand(rsp, (argc + 2) * kPointerSize)); |
+ |
+ // Enter an internal frame. |
+ __ EnterInternalFrame(); |
+ |
+ // Push the receiver and the name of the function. |
+ __ push(rdx); |
+ __ push(rbx); |
+ |
+ // Call the entry. |
+ CEntryStub stub; |
+ __ movq(rax, Immediate(2)); |
+ __ movq(rbx, f); |
+ __ CallStub(&stub); |
+ |
+ // Move result to rdi and exit the internal frame. |
+ __ movq(rdi, rax); |
+ __ LeaveInternalFrame(); |
+ |
+ // Check if the receiver is a global object of some sort. |
+ Label invoke, global; |
+ __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); // receiver |
+ __ testq(rdx, Immediate(kSmiTagMask)); |
+ __ j(zero, &invoke); |
+ __ movq(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); |
+ __ movzxbq(rcx, FieldOperand(rcx, Map::kInstanceTypeOffset)); |
+ __ cmpq(rcx, Immediate(static_cast<int8_t>(JS_GLOBAL_OBJECT_TYPE))); |
+ __ j(equal, &global); |
+ __ cmpq(rcx, Immediate(static_cast<int8_t>(JS_BUILTINS_OBJECT_TYPE))); |
+ __ j(not_equal, &invoke); |
+ |
+ // Patch the receiver on the stack. |
+ __ bind(&global); |
+ __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
+ __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); |
+ |
+ // Invoke the function. |
+ ParameterCount actual(argc); |
+ __ bind(&invoke); |
+ __ InvokeFunction(rdi, actual, JUMP_FUNCTION); |
+} |
+ |
+void CallIC::GenerateMegamorphic(MacroAssembler* a, int b) { |
+ UNIMPLEMENTED(); |
+} |
+ |
+void CallIC::GenerateNormal(MacroAssembler* a, int b) { |
+ UNIMPLEMENTED(); |
+} |
+ |
+ |
+const int LoadIC::kOffsetToLoadInstruction = 20; |
+ |
+ |
void LoadIC::ClearInlinedVersion(Address address) { |
UNIMPLEMENTED(); |
} |
+ |
void LoadIC::Generate(MacroAssembler* masm, ExternalReference const& f) { |
- masm->int3(); // UNIMPLEMENTED. |
+ // ----------- S t a t e ------------- |
+ // -- rcx : name |
+ // -- rsp[0] : return address |
+ // -- rsp[8] : receiver |
+ // ----------------------------------- |
+ |
+ __ movq(rax, Operand(rsp, kPointerSize)); |
+ |
+ // Move the return address below the arguments. |
+ __ pop(rbx); |
+ __ push(rax); |
+ __ push(rcx); |
+ __ push(rbx); |
+ |
+ // Perform tail call to the entry. |
+ __ TailCallRuntime(f, 2); |
} |
+ |
void LoadIC::GenerateArrayLength(MacroAssembler* masm) { |
masm->int3(); // UNIMPLEMENTED. |
} |