Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1168)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 594009: Always load the JavaScript builtins code entry from the JavaScript... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 21 matching lines...) Expand all
32 #include "assembler-x64.h" 32 #include "assembler-x64.h"
33 #include "macro-assembler-x64.h" 33 #include "macro-assembler-x64.h"
34 #include "serialize.h" 34 #include "serialize.h"
35 #include "debug.h" 35 #include "debug.h"
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40 MacroAssembler::MacroAssembler(void* buffer, int size) 40 MacroAssembler::MacroAssembler(void* buffer, int size)
41 : Assembler(buffer, size), 41 : Assembler(buffer, size),
42 unresolved_(0),
43 generating_stub_(false), 42 generating_stub_(false),
44 allow_stub_calls_(true), 43 allow_stub_calls_(true),
45 code_object_(Heap::undefined_value()) { 44 code_object_(Heap::undefined_value()) {
46 } 45 }
47 46
48 47
49 void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) { 48 void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) {
50 movq(destination, Operand(r13, index << kPointerSizeLog2)); 49 movq(destination, Operand(r13, index << kPointerSizeLog2));
51 } 50 }
52 51
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 407
409 void MacroAssembler::JumpToRuntime(const ExternalReference& ext, 408 void MacroAssembler::JumpToRuntime(const ExternalReference& ext,
410 int result_size) { 409 int result_size) {
411 // Set the entry point and jump to the C entry runtime stub. 410 // Set the entry point and jump to the C entry runtime stub.
412 movq(rbx, ext); 411 movq(rbx, ext);
413 CEntryStub ces(result_size); 412 CEntryStub ces(result_size);
414 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); 413 jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
415 } 414 }
416 415
417 416
417 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag) {
418 // Calls are not allowed in some stubs.
419 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls());
420
421 // Rely on the assertion to check that the number of provided
422 // arguments match the expected number of arguments. Fake a
423 // parameter count to avoid emitting code to do the check.
424 ParameterCount expected(0);
425 GetBuiltinEntry(rdx, id);
426 InvokeCode(rdx, expected, expected, flag);
427 }
428
429
418 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { 430 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) {
419 bool resolved; 431 // Load the JavaScript builtin function from the builtins object
420 Handle<Code> code = ResolveBuiltin(id, &resolved); 432 // using the target register as a scratch register.
421 433 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
422 const char* name = Builtins::GetName(id); 434 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset));
423 int argc = Builtins::GetArgumentsCount(id); 435 int builtins_offset =
424 436 JSBuiltinsObject::kJSBuiltinsOffset + (id * kPointerSize);
425 movq(target, code, RelocInfo::EMBEDDED_OBJECT); 437 movq(rdi, FieldOperand(target, builtins_offset));
426 if (!resolved) { 438 // Load the code entry point from the function into the target register.
427 uint32_t flags = 439 movq(target, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
428 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | 440 movq(target, FieldOperand(target, SharedFunctionInfo::kCodeOffset));
429 Bootstrapper::FixupFlagsUseCodeObject::encode(true);
430 Unresolved entry = { pc_offset() - sizeof(intptr_t), flags, name };
431 unresolved_.Add(entry);
432 }
433 addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag)); 441 addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag));
434 } 442 }
435 443
436 Handle<Code> MacroAssembler::ResolveBuiltin(Builtins::JavaScript id,
437 bool* resolved) {
438 // Move the builtin function into the temporary function slot by
439 // reading it from the builtins object. NOTE: We should be able to
440 // reduce this to two instructions by putting the function table in
441 // the global object instead of the "builtins" object and by using a
442 // real register for the function.
443 movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)));
444 movq(rdx, FieldOperand(rdx, GlobalObject::kBuiltinsOffset));
445 int builtins_offset =
446 JSBuiltinsObject::kJSBuiltinsOffset + (id * kPointerSize);
447 movq(rdi, FieldOperand(rdx, builtins_offset));
448 444
449 return Builtins::GetCode(id, resolved);
450 }
451
452
453 void MacroAssembler::Set(Register dst, int64_t x) { 445 void MacroAssembler::Set(Register dst, int64_t x) {
454 if (x == 0) { 446 if (x == 0) {
455 xor_(dst, dst); 447 xor_(dst, dst);
456 } else if (is_int32(x)) { 448 } else if (is_int32(x)) {
457 movq(dst, Immediate(static_cast<int32_t>(x))); 449 movq(dst, Immediate(static_cast<int32_t>(x)));
458 } else if (is_uint32(x)) { 450 } else if (is_uint32(x)) {
459 movl(dst, Immediate(static_cast<uint32_t>(x))); 451 movl(dst, Immediate(static_cast<uint32_t>(x)));
460 } else { 452 } else {
461 movq(dst, x, RelocInfo::NONE); 453 movq(dst, x, RelocInfo::NONE);
462 } 454 }
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 void MacroAssembler::DebugBreak() { 1769 void MacroAssembler::DebugBreak() {
1778 ASSERT(allow_stub_calls()); 1770 ASSERT(allow_stub_calls());
1779 xor_(rax, rax); // no arguments 1771 xor_(rax, rax); // no arguments
1780 movq(rbx, ExternalReference(Runtime::kDebugBreak)); 1772 movq(rbx, ExternalReference(Runtime::kDebugBreak));
1781 CEntryStub ces(1); 1773 CEntryStub ces(1);
1782 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); 1774 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK);
1783 } 1775 }
1784 #endif // ENABLE_DEBUGGER_SUPPORT 1776 #endif // ENABLE_DEBUGGER_SUPPORT
1785 1777
1786 1778
1787 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag) {
1788 bool resolved;
1789 Handle<Code> code = ResolveBuiltin(id, &resolved);
1790
1791 // Calls are not allowed in some stubs.
1792 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls());
1793
1794 // Rely on the assertion to check that the number of provided
1795 // arguments match the expected number of arguments. Fake a
1796 // parameter count to avoid emitting code to do the check.
1797 ParameterCount expected(0);
1798 InvokeCode(Handle<Code>(code),
1799 expected,
1800 expected,
1801 RelocInfo::CODE_TARGET,
1802 flag);
1803
1804 const char* name = Builtins::GetName(id);
1805 int argc = Builtins::GetArgumentsCount(id);
1806 // The target address for the jump is stored as an immediate at offset
1807 // kInvokeCodeAddressOffset.
1808 if (!resolved) {
1809 uint32_t flags =
1810 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) |
1811 Bootstrapper::FixupFlagsUseCodeObject::encode(false);
1812 Unresolved entry =
1813 { pc_offset() - kCallTargetAddressOffset, flags, name };
1814 unresolved_.Add(entry);
1815 }
1816 }
1817
1818
1819 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 1779 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
1820 const ParameterCount& actual, 1780 const ParameterCount& actual,
1821 Handle<Code> code_constant, 1781 Handle<Code> code_constant,
1822 Register code_register, 1782 Register code_register,
1823 Label* done, 1783 Label* done,
1824 InvokeFlag flag) { 1784 InvokeFlag flag) {
1825 bool definitely_matches = false; 1785 bool definitely_matches = false;
1826 Label invoke; 1786 Label invoke;
1827 if (expected.is_immediate()) { 1787 if (expected.is_immediate()) {
1828 ASSERT(actual.is_immediate()); 1788 ASSERT(actual.is_immediate());
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 CodePatcher::~CodePatcher() { 2542 CodePatcher::~CodePatcher() {
2583 // Indicate that code has changed. 2543 // Indicate that code has changed.
2584 CPU::FlushICache(address_, size_); 2544 CPU::FlushICache(address_, size_);
2585 2545
2586 // Check that the code was patched as expected. 2546 // Check that the code was patched as expected.
2587 ASSERT(masm_.pc_ == address_ + size_); 2547 ASSERT(masm_.pc_ == address_ + size_);
2588 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2548 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2589 } 2549 }
2590 2550
2591 } } // namespace v8::internal 2551 } } // namespace v8::internal
OLDNEW
« src/arm/macro-assembler-arm.cc ('K') | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698