From 3ccdce6d830a2041ca7aa860d835298382420b86 Mon Sep 17 00:00:00 2001 From: "feng@chromium.org" Date: Mon, 10 Nov 2008 22:53:19 +0000 Subject: [PATCH] Fix CALL_NON_FUNCTION. Using two flags to specify the state of targets: 1) FixupIsPCRelative specifies where to patch (relative to pc or at pc); 2) FixupUseCodeObject specifies what to patch (code object or start address). Review URL: http://codereview.chromium.org/10233 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@727 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/bootstrapper.cc | 15 ++++++++++++--- src/bootstrapper.h | 3 ++- src/codegen-arm.cc | 5 ++++- src/macro-assembler-arm.cc | 8 ++++++-- src/macro-assembler-ia32.cc | 6 ++++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index d08baa1cd..ce25d00e4 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -205,11 +205,20 @@ bool PendingFixups::Process(Handle builtins) { Code* code = Code::cast(code_[i]); Address pc = code->instruction_start() + pc_[i]; bool is_pc_relative = Bootstrapper::FixupFlagsIsPCRelative::decode(flags); - if (is_pc_relative) { - Assembler::set_target_address_at(pc, f->code()->instruction_start()); + bool use_code_object = Bootstrapper::FixupFlagsUseCodeObject::decode(flags); + + if (use_code_object) { + if (is_pc_relative) { + Assembler::set_target_address_at( + pc, reinterpret_cast
(f->code())); + } else { + *reinterpret_cast(pc) = f->code(); + } } else { - *reinterpret_cast(pc) = f->code(); + ASSERT(is_pc_relative); + Assembler::set_target_address_at(pc, f->code()->instruction_start()); } + LOG(StringEvent("resolved", name)); } Clear(); diff --git a/src/bootstrapper.h b/src/bootstrapper.h index 0b0784e00..908217d02 100644 --- a/src/bootstrapper.h +++ b/src/bootstrapper.h @@ -66,7 +66,8 @@ class Bootstrapper : public AllStatic { // Encoding/decoding support for fixup flags. class FixupFlagsIsPCRelative: public BitField {}; - class FixupFlagsArgumentsCount: public BitField {}; + class FixupFlagsUseCodeObject: public BitField {}; + class FixupFlagsArgumentsCount: public BitField {}; }; }} // namespace v8::internal diff --git a/src/codegen-arm.cc b/src/codegen-arm.cc index 565726ea5..989984179 100644 --- a/src/codegen-arm.cc +++ b/src/codegen-arm.cc @@ -4283,7 +4283,10 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { // Slow-case: Non-function called. __ bind(&slow); __ mov(r0, Operand(argc_)); // Setup the number of arguments. - __ InvokeBuiltin(Builtins::CALL_NON_FUNCTION, JUMP_JS); + __ mov(r2, Operand(0)); + __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); + __ Jump(Handle(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), + RelocInfo::CODE_TARGET); } diff --git a/src/macro-assembler-arm.cc b/src/macro-assembler-arm.cc index 2e957e4a1..616a9bf45 100644 --- a/src/macro-assembler-arm.cc +++ b/src/macro-assembler-arm.cc @@ -818,7 +818,8 @@ void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, int argc = Builtins::GetArgumentsCount(id); uint32_t flags = Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | - Bootstrapper::FixupFlagsIsPCRelative::encode(true); + Bootstrapper::FixupFlagsIsPCRelative::encode(true) | + Bootstrapper::FixupFlagsUseCodeObject::encode(false); Unresolved entry = { pc_offset() - sizeof(Instr), flags, name }; unresolved_.Add(entry); } @@ -835,10 +836,13 @@ void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { int argc = Builtins::GetArgumentsCount(id); uint32_t flags = Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | - Bootstrapper::FixupFlagsIsPCRelative::encode(true); + Bootstrapper::FixupFlagsIsPCRelative::encode(true) | + Bootstrapper::FixupFlagsUseCodeObject::encode(true); Unresolved entry = { pc_offset() - sizeof(Instr), flags, name }; unresolved_.Add(entry); } + + add(target, target, Operand(Code::kHeaderSize - kHeapObjectTag)); } diff --git a/src/macro-assembler-ia32.cc b/src/macro-assembler-ia32.cc index 72808de4d..d545626df 100644 --- a/src/macro-assembler-ia32.cc +++ b/src/macro-assembler-ia32.cc @@ -873,7 +873,8 @@ void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag) { if (!resolved) { uint32_t flags = Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | - Bootstrapper::FixupFlagsIsPCRelative::encode(true); + Bootstrapper::FixupFlagsIsPCRelative::encode(true) | + Bootstrapper::FixupFlagsUseCodeObject::encode(false); Unresolved entry = { pc_offset() - sizeof(int32_t), flags, name }; unresolved_.Add(entry); } @@ -891,7 +892,8 @@ void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { if (!resolved) { uint32_t flags = Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | - Bootstrapper::FixupFlagsIsPCRelative::encode(false); + Bootstrapper::FixupFlagsIsPCRelative::encode(false) | + Bootstrapper::FixupFlagsUseCodeObject::encode(true); Unresolved entry = { pc_offset() - sizeof(int32_t), flags, name }; unresolved_.Add(entry); } -- 2.34.1