From: whesse@chromium.org Date: Tue, 16 Jun 2009 08:24:42 +0000 (+0000) Subject: X64 platform: Add more register allocator functions. X-Git-Tag: upstream/4.7.83~23900 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb03c8414fc68668dc0066ae6e8aff474b9eabc2;p=platform%2Fupstream%2Fv8.git X64 platform: Add more register allocator functions. Review URL: http://codereview.chromium.org/125131 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2177 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/SConscript b/src/SConscript index b96756756..f1ca8753c 100755 --- a/src/SConscript +++ b/src/SConscript @@ -77,6 +77,7 @@ SOURCES = { 'x64/debug-x64.cc', 'x64/frames-x64.cc', 'x64/ic-x64.cc', 'x64/jump-target-x64.cc', 'x64/macro-assembler-x64.cc', # 'x64/regexp-macro-assembler-x64.cc', + 'x64/register-allocator-x64.cc', 'x64/stub-cache-x64.cc', 'x64/virtual-frame-x64.cc' ], 'simulator:arm': ['arm/simulator-arm.cc'], diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index 0b94a4082..ec27983cc 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -151,11 +151,6 @@ void RelocInfo::apply(int delta) { if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { intptr_t* p = reinterpret_cast(pc_); *p -= delta; // relocate entry - } else if (rmode_ == JS_RETURN && IsCallInstruction()) { - // Special handling of js_return when a break point is set (call - // instruction has been inserted). - intptr_t* p = reinterpret_cast(pc_ + 1); - *p -= delta; // relocate entry } else if (IsInternalReference(rmode_)) { // absolute code pointer inside code object moves with the code object. intptr_t* p = reinterpret_cast(pc_); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index e60286a3e..c47bfccf1 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -531,8 +531,10 @@ void MacroAssembler::InvokeFunction(Register function, ASSERT(function.is(rdi)); movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); - movq(rbx, FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); + movl(rbx, FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); movq(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset)); + // Advances rdx to the end of the Code object headers, to the start of + // the executable code. lea(rdx, FieldOperand(rdx, Code::kHeaderSize)); ParameterCount expected(rbx); diff --git a/src/x64/register-allocator-x64.cc b/src/x64/register-allocator-x64.cc index 209aa2d30..3aba60fb2 100644 --- a/src/x64/register-allocator-x64.cc +++ b/src/x64/register-allocator-x64.cc @@ -25,3 +25,66 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "v8.h" + +#include "codegen-inl.h" +#include "register-allocator-inl.h" + +namespace v8 { +namespace internal { + +// ------------------------------------------------------------------------- +// Result implementation. + +void Result::ToRegister() { + ASSERT(is_valid()); + if (is_constant()) { + // TODO(X64): Handle constant results. + /* + Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(); + ASSERT(fresh.is_valid()); + if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { + CodeGeneratorScope::Current()->LoadUnsafeSmi(fresh.reg(), handle()); + } else { + CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), + Immediate(handle())); + } + // This result becomes a copy of the fresh one. + *this = fresh; + */ + } + ASSERT(is_register()); +} + + +void Result::ToRegister(Register target) { + ASSERT(is_valid()); + if (!is_register() || !reg().is(target)) { + Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(target); + ASSERT(fresh.is_valid()); + if (is_register()) { + CodeGeneratorScope::Current()->masm()->movq(fresh.reg(), reg()); + } else { + ASSERT(is_constant()); + /* + TODO(X64): Handle constant results. + if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { + CodeGeneratorScope::Current()->LoadUnsafeSmi(fresh.reg(), handle()); + } else { + CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), + Immediate(handle())); + } + */ + } + *this = fresh; + } else if (is_register() && reg().is(target)) { + ASSERT(CodeGeneratorScope::Current()->has_valid_frame()); + CodeGeneratorScope::Current()->frame()->Spill(target); + ASSERT(CodeGeneratorScope::Current()->allocator()->count(target) == 1); + } + ASSERT(is_register()); + ASSERT(reg().is(target)); +} + + +} } // namespace v8::internal diff --git a/src/x64/register-allocator-x64.h b/src/x64/register-allocator-x64.h index d97463914..86727962e 100644 --- a/src/x64/register-allocator-x64.h +++ b/src/x64/register-allocator-x64.h @@ -35,7 +35,7 @@ class RegisterAllocatorConstants : public AllStatic { public: // Register allocation is not yet implemented on x64, but C++ // forbids 0-length arrays so we use 1 as the number of registers. - static const int kNumRegisters = 16; + static const int kNumRegisters = 12; static const int kInvalidRegister = -1; }; diff --git a/src/x64/virtual-frame-x64.cc b/src/x64/virtual-frame-x64.cc index 7dff02ca1..e6975fa43 100644 --- a/src/x64/virtual-frame-x64.cc +++ b/src/x64/virtual-frame-x64.cc @@ -100,6 +100,8 @@ void VirtualFrame::Exit() { // short. We need the return sequence to be a least the size of a // call instruction to support patching the exit code in the // debugger. See VisitReturnStatement for the full return sequence. + // TODO(X64): A patched call will be very long now. Make sure we + // have enough room. __ movq(rsp, rbp); stack_pointer_ = frame_pointer(); for (int i = element_count() - 1; i > stack_pointer_; i--) {