X64 platform: Add more register allocator functions.
authorwhesse@chromium.org <whesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Jun 2009 08:24:42 +0000 (08:24 +0000)
committerwhesse@chromium.org <whesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Jun 2009 08:24:42 +0000 (08:24 +0000)
Review URL: http://codereview.chromium.org/125131

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2177 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/SConscript
src/x64/assembler-x64-inl.h
src/x64/macro-assembler-x64.cc
src/x64/register-allocator-x64.cc
src/x64/register-allocator-x64.h
src/x64/virtual-frame-x64.cc

index b96756756c8e668b94495399a299909d3b0fc17c..f1ca8753c21d99a781c3552669824fd31394b0cd 100755 (executable)
@@ -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'],
index 0b94a4082bfc77cec2aae358de2ea29a8caa887d..ec27983cc15982a312860f75722411a430453f51 100644 (file)
@@ -151,11 +151,6 @@ void RelocInfo::apply(int delta) {
   if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
     intptr_t* p = reinterpret_cast<intptr_t*>(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<intptr_t*>(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<intptr_t*>(pc_);
index e60286a3e991b06b07e939ab22bd010ff2c0a640..c47bfccf13034c61062f844628a6cb25e896c604 100644 (file)
@@ -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);
index 209aa2d3070e48da7890e9457e64fe4718cfd782..3aba60fb2d12d635933b82054965965a8bc5d179 100644 (file)
 // (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
index d97463914e62d59e3f24621a78e4bc0f1a8906ea..86727962ee43ce9673664618ffade51034765b71 100644 (file)
@@ -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;
 };
 
index 7dff02ca1bb6be6817e0bf9cc58bb28d820e41f2..e6975fa434a90b67835bc3c05c0808a33aa7e7d5 100644 (file)
@@ -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--) {