Commit 094d17ff authored by ager@chromium.org's avatar ager@chromium.org

x64: Generate code for loading from, storing to and calling properties.

Review URL: http://codereview.chromium.org/141056

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2245 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ad970953
......@@ -141,6 +141,9 @@ static void GenerateCheckNonObjectOrLoaded(MacroAssembler* masm, Label* miss,
}
const int LoadIC::kOffsetToLoadInstruction = 13;
void LoadIC::GenerateArrayLength(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- ecx : name
......
......@@ -221,7 +221,7 @@ class LoadIC: public IC {
// The offset from the inlined patch site to the start of the
// inlined load instruction. It is 7 bytes (test eax, imm) plus
// 6 bytes (jne slow_label).
static const int kOffsetToLoadInstruction = 13;
static const int kOffsetToLoadInstruction;
private:
static void Generate(MacroAssembler* masm, const ExternalReference& f);
......
......@@ -1875,16 +1875,4 @@ void BreakLocationIterator::SetDebugBreakAtReturn() {
UNIMPLEMENTED();
}
void CallIC::Generate(MacroAssembler* a, int b, ExternalReference const& c) {
UNIMPLEMENTED();
}
void CallIC::GenerateMegamorphic(MacroAssembler* a, int b) {
UNIMPLEMENTED();
}
void CallIC::GenerateNormal(MacroAssembler* a, int b) {
UNIMPLEMENTED();
}
} } // namespace v8::internal
This diff is collapsed.
......@@ -80,8 +80,9 @@ void ExitFrame::Iterate(ObjectVisitor* a) const {
}
byte* InternalFrame::GetCallerStackPointer() const {
UNIMPLEMENTED();
return NULL;
// Internal frames have no arguments. The stack pointer of the
// caller is at a fixed offset from the frame pointer.
return fp() + StandardFrameConstants::kCallerSPOffset;
}
byte* JavaScriptFrame::GetCallerStackPointer() const {
......
......@@ -54,11 +54,29 @@ void KeyedStoreIC::RestoreInlinedVersion(Address address) {
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 @@ Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) {
}
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 @@ Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
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.
}
......
......@@ -842,6 +842,42 @@ Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) {
}
Result VirtualFrame::CallLoadIC(RelocInfo::Mode mode) {
// Name and receiver are on the top of the frame. The IC expects
// name in rcx and receiver on the stack. It does not drop the
// receiver.
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
Result name = Pop();
PrepareForCall(1, 0); // One stack arg, not callee-dropped.
name.ToRegister(rcx);
name.Unuse();
return RawCallCodeObject(ic, mode);
}
Result VirtualFrame::CallKeyedLoadIC(RelocInfo::Mode mode) {
// Key and receiver are on top of the frame. The IC expects them on
// the stack. It does not drop them.
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
PrepareForCall(2, 0); // Two stack args, neither callee-dropped.
return RawCallCodeObject(ic, mode);
}
Result VirtualFrame::CallKeyedStoreIC() {
// Value, key, and receiver are on the top of the frame. The IC
// expects value in rax and key and receiver on the stack. It does
// not drop the key and receiver.
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
// TODO(1222589): Make the IC grab the values from the stack.
Result value = Pop();
PrepareForCall(2, 0); // Two stack args, neither callee-dropped.
value.ToRegister(rax);
value.Unuse();
return RawCallCodeObject(ic, RelocInfo::CODE_TARGET);
}
Result VirtualFrame::CallCallIC(RelocInfo::Mode mode,
int arg_count,
int loop_nesting) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment