Author: [email protected]
Date: Tue May 12 03:33:40 2009
New Revision: 1913

Modified:
    branches/bleeding_edge/src/disassembler.cc
    branches/bleeding_edge/src/globals.h
    branches/bleeding_edge/src/ia32/cpu-ia32.cc
    branches/bleeding_edge/src/log.cc
    branches/bleeding_edge/src/objects.cc
    branches/bleeding_edge/src/runtime.cc
    branches/bleeding_edge/src/x64/assembler-x64-inl.h
    branches/bleeding_edge/src/x64/codegen-x64.h
    branches/bleeding_edge/src/x64/cpu-x64.cc

Log:
X64: General fixes - added inline definitions and changed some places to  
intptr_t.

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


Modified: branches/bleeding_edge/src/disassembler.cc
==============================================================================
--- branches/bleeding_edge/src/disassembler.cc  (original)
+++ branches/bleeding_edge/src/disassembler.cc  Tue May 12 03:33:40 2009
@@ -43,9 +43,10 @@
  void Disassembler::Dump(FILE* f, byte* begin, byte* end) {
    for (byte* pc = begin; pc < end; pc++) {
      if (f == NULL) {
-      PrintF("%p  %4d  %02x\n", pc, pc - begin, *pc);
+      PrintF("%" V8PRIxPTR "  %4" V8PRIdPTR "  %02x\n", pc, pc - begin,  
*pc);
      } else {
-      fprintf(f, "%p  %4d  %02x\n", pc, pc - begin, *pc);
+      fprintf(f, "%" V8PRIxPTR "  %4" V8PRIdPTR "  %02x\n",
+              reinterpret_cast<uintptr_t>(pc), pc - begin, *pc);
      }
    }
  }
@@ -144,8 +145,8 @@
          // raw pointer embedded in code stream, e.g., jump table
          byte* ptr = *reinterpret_cast<byte**>(pc);
          OS::SNPrintF(decode_buffer,
-                     "%08x      jump table entry %4d",
-                     reinterpret_cast<int32_t>(ptr),
+                     "%08" V8PRIxPTR "      jump table entry %4" V8PRIdPTR,
+                     ptr,
                       ptr - begin);
          pc += 4;
        } else {

Modified: branches/bleeding_edge/src/globals.h
==============================================================================
--- branches/bleeding_edge/src/globals.h        (original)
+++ branches/bleeding_edge/src/globals.h        Tue May 12 03:33:40 2009
@@ -86,7 +86,8 @@
  #define V8_PTR_PREFIX ""
  #endif

-#define V8PRIp V8_PTR_PREFIX "x"
+#define V8PRIxPTR V8_PTR_PREFIX "x"
+#define V8PRIdPTR V8_PTR_PREFIX "d"

  // Code-point values in Unicode 4.0 are 21 bits wide.
  typedef uint16_t uc16;

Modified: branches/bleeding_edge/src/ia32/cpu-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/ia32/cpu-ia32.cc (original)
+++ branches/bleeding_edge/src/ia32/cpu-ia32.cc Tue May 12 03:33:40 2009
@@ -46,7 +46,7 @@
    // is patched on an intel CPU the core performing the patching will have  
its
    // own instruction cache updated automatically.

-  // If flushing of the instruction cache becomes necessary Windows have  
the
+  // If flushing of the instruction cache becomes necessary Windows has the
    // API function FlushInstructionCache.
  }


Modified: branches/bleeding_edge/src/log.cc
==============================================================================
--- branches/bleeding_edge/src/log.cc   (original)
+++ branches/bleeding_edge/src/log.cc   Tue May 12 03:33:40 2009
@@ -631,7 +631,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_handles) return;
    LogMessageBuilder msg;
-  msg.Append("%s,0x%%"V8PRIp"\n", name, location);
+  msg.Append("%s,0x%%" V8PRIxPTR "\n", name, location);
    msg.WriteToLogFile();
  #endif
  }
@@ -850,7 +850,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log) return;
    LogMessageBuilder msg;
-  msg.Append("new,%s,0x%%"V8PRIp",%u\n", name, object,
+  msg.Append("new,%s,0x%%" V8PRIxPTR ",%u\n", name, object,
               static_cast<unsigned int>(size));
    msg.WriteToLogFile();
  #endif
@@ -861,7 +861,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log) return;
    LogMessageBuilder msg;
-  msg.Append("delete,%s,0x%%"V8PRIp"\n", name, object);
+  msg.Append("delete,%s,0x%%" V8PRIxPTR "\n", name, object);
    msg.WriteToLogFile();
  #endif
  }
@@ -871,7 +871,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_code) return;
    LogMessageBuilder msg;
-  msg.Append("code-creation,%s,0x%"V8PRIp",%d,\"", tag, code->address(),
+  msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"", tag,  
code->address(),
               code->ExecutableSize());
    for (const char* p = comment; *p != '\0'; p++) {
      if (*p == '"') {
@@ -892,8 +892,8 @@
    LogMessageBuilder msg;
    SmartPointer<char> str =
        name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
-  msg.Append("code-creation,%s,0x%"V8PRIp",%d,\"%s\"\n", tag,  
code->address(),
-             code->ExecutableSize(), *str);
+  msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"%s\"\n",
+             tag, code->address(), code->ExecutableSize(), *str);
    msg.WriteToLogFile();
  #endif
  }
@@ -908,7 +908,7 @@
        name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
    SmartPointer<char> sourcestr =
        source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
-  msg.Append("code-creation,%s,0x%"V8PRIp",%d,\"%s %s:%d\"\n",
+  msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"%s %s:%d\"\n",
               tag, code->address(),
               code->ExecutableSize(),
               *str, *sourcestr, line);
@@ -921,7 +921,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_code) return;
    LogMessageBuilder msg;
-  msg.Append("code-creation,%s,0x%"V8PRIp",%d,\"args_count: %d\"\n", tag,
+  msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"args_count: %d\"\n",  
tag,
               code->address(),
               code->ExecutableSize(),
               args_count);
@@ -934,7 +934,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_code) return;
    LogMessageBuilder msg;
-  msg.Append("code-creation,%s,0x%"V8PRIp",%d,\"", "RegExp",
+  msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"", "RegExp",
               code->address(),
               code->ExecutableSize());
    msg.AppendDetailed(source, false);
@@ -948,7 +948,9 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_code) return;
    LogMessageBuilder msg;
-  msg.Append("code-allocate,0x%"V8PRIp",0x%"V8PRIp"\n", code->address(),  
assem);
+  msg.Append("code-allocate,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n",
+             code->address(),
+             assem);
    msg.WriteToLogFile();
  #endif
  }
@@ -958,7 +960,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_code) return;
    LogMessageBuilder msg;
-  msg.Append("code-move,0x%"V8PRIp",0x%"V8PRIp"\n", from, to);
+  msg.Append("code-move,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n", from, to);
    msg.WriteToLogFile();
  #endif
  }
@@ -968,7 +970,7 @@
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (!Log::is_enabled() || !FLAG_log_code) return;
    LogMessageBuilder msg;
-  msg.Append("code-delete,0x%"V8PRIp"\n", from);
+  msg.Append("code-delete,0x%" V8PRIxPTR "\n", from);
    msg.WriteToLogFile();
  #endif
  }
@@ -1074,13 +1076,13 @@
  void Logger::TickEvent(TickSample* sample, bool overflow) {
    if (!Log::is_enabled() || !FLAG_prof) return;
    LogMessageBuilder msg;
-  msg.Append("tick,0x%"V8PRIp",0x%"V8PRIp",%d", sample->pc, sample->sp,
-             static_cast<int>(sample->state));
+  msg.Append("tick,0x%" V8PRIxPTR ",0x%" V8PRIxPTR ",%d",
+             sample->pc, sample->sp, static_cast<int>(sample->state));
    if (overflow) {
      msg.Append(",overflow");
    }
    for (int i = 0; i < sample->frames_count; ++i) {
-    msg.Append(",0x%"V8PRIp, sample->stack[i]);
+    msg.Append(",0x%" V8PRIxPTR, sample->stack[i]);
    }
    msg.Append('\n');
    msg.WriteToLogFile();

Modified: branches/bleeding_edge/src/objects.cc
==============================================================================
--- branches/bleeding_edge/src/objects.cc       (original)
+++ branches/bleeding_edge/src/objects.cc       Tue May 12 03:33:40 2009
@@ -6725,7 +6725,10 @@
    virtual HashFunction GetHashFunction() { return MapNameHash; }

    static uint32_t MapNameHashHelper(Map* map, String* name) {
-    return reinterpret_cast<uint32_t>(map) ^ name->Hash();
+    // Uses only lower 32 bits if pointers are larger.
+    uintptr_t addr_hash =
+        static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map));
+    return addr_hash ^ name->Hash();
    }

    static uint32_t MapNameHash(Object* obj) {

Modified: branches/bleeding_edge/src/runtime.cc
==============================================================================
--- branches/bleeding_edge/src/runtime.cc       (original)
+++ branches/bleeding_edge/src/runtime.cc       Tue May 12 03:33:40 2009
@@ -4442,10 +4442,16 @@
  // compiler to do the right thing.
  //
  // TODO(1236026): This is a non-portable hack that should be removed.
+// TODO(x64): Definitely!
  typedef uint64_t ObjectPair;
  static inline ObjectPair MakePair(Object* x, Object* y) {
+#if V8_HOST_ARCH_64_BIT
+  UNIMPLEMENTED();
+  return 0;
+#else
    return reinterpret_cast<uint32_t>(x) |
        (reinterpret_cast<ObjectPair>(y) << 32);
+#endif
  }


@@ -6031,6 +6037,11 @@
    Object* result = Runtime_CheckExecutionState(args);
    if (result->IsFailure()) return result;

+#if V8_HOST_ARCH_64_BIT
+  UNIMPLEMENTED();
+  return Heap::undefined_value();
+#else
+
    static const int kMaxCFramesSize = 200;
    ScopedVector<OS::StackFrame> frames(kMaxCFramesSize);
    int frames_count = OS::StackWalk(frames);
@@ -6062,6 +6073,7 @@
      frames_array->set(i, *frame_value);
    }
    return *Factory::NewJSArrayWithElements(frames_array);
+#endif  // V8_HOST_ARCH_64_BIT
  }



Modified: branches/bleeding_edge/src/x64/assembler-x64-inl.h
==============================================================================
--- branches/bleeding_edge/src/x64/assembler-x64-inl.h  (original)
+++ branches/bleeding_edge/src/x64/assembler-x64-inl.h  Tue May 12 03:33:40  
2009
@@ -28,6 +28,8 @@
  #ifndef V8_X64_ASSEMBLER_X64_INL_H_
  #define V8_X64_ASSEMBLER_X64_INL_H_

+#include "cpu.h"
+
  namespace v8 { namespace internal {

  Condition NegateCondition(Condition cc) {
@@ -35,6 +37,24 @@
  }


+// The modes possibly affected by apply must be in kApplyMask.
+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_);
+    *p += delta;  // relocate entry
+  }
+}
+
+
  Address RelocInfo::target_address() {
    ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
    return Assembler::target_address_at(pc_);
@@ -61,6 +81,71 @@
  byte* Assembler::target_address_at(byte* location) {
    UNIMPLEMENTED();
    return NULL;
+}
+
+
+Object* RelocInfo::target_object() {
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
+  return *reinterpret_cast<Object**>(pc_);
+}
+
+
+Object** RelocInfo::target_object_address() {
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
+  return reinterpret_cast<Object**>(pc_);
+}
+
+
+Address* RelocInfo::target_reference_address() {
+  ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
+  return reinterpret_cast<Address*>(pc_);
+}
+
+
+void RelocInfo::set_target_object(Object* target) {
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
+  *reinterpret_cast<Object**>(pc_) = target;
+}
+
+
+bool RelocInfo::IsCallInstruction() {
+  UNIMPLEMENTED();  // IA32 code below.
+  return *pc_ == 0xE8;
+}
+
+
+Address RelocInfo::call_address() {
+  UNIMPLEMENTED();  // IA32 code below.
+  ASSERT(IsCallInstruction());
+  return Assembler::target_address_at(pc_ + 1);
+}
+
+
+void RelocInfo::set_call_address(Address target) {
+  UNIMPLEMENTED();  // IA32 code below.
+  ASSERT(IsCallInstruction());
+  Assembler::set_target_address_at(pc_ + 1, target);
+}
+
+
+Object* RelocInfo::call_object() {
+  UNIMPLEMENTED();  // IA32 code below.
+  ASSERT(IsCallInstruction());
+  return *call_object_address();
+}
+
+
+void RelocInfo::set_call_object(Object* target) {
+  UNIMPLEMENTED();  // IA32 code below.
+  ASSERT(IsCallInstruction());
+  *call_object_address() = target;
+}
+
+
+Object** RelocInfo::call_object_address() {
+  UNIMPLEMENTED();  // IA32 code below.
+  ASSERT(IsCallInstruction());
+  return reinterpret_cast<Object**>(pc_ + 1);
  }

  } }  // namespace v8::internal

Modified: branches/bleeding_edge/src/x64/codegen-x64.h
==============================================================================
--- branches/bleeding_edge/src/x64/codegen-x64.h        (original)
+++ branches/bleeding_edge/src/x64/codegen-x64.h        Tue May 12 03:33:40 2009
@@ -473,7 +473,15 @@

    void CheckStack();

+  struct InlineRuntimeLUT {
+    void (CodeGenerator::*method)(ZoneList<Expression*>*);
+    const char* name;
+  };
+  static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name);
    bool CheckForInlineRuntimeCall(CallRuntime* node);
+  static bool PatchInlineRuntimeEntry(Handle<String> name,
+                                      const InlineRuntimeLUT& new_entry,
+                                      InlineRuntimeLUT* old_entry);
    Handle<JSFunction> BuildBoilerplate(FunctionLiteral* node);
    void ProcessDeclarations(ZoneList<Declaration*>* declarations);

@@ -603,6 +611,8 @@
    // called from spilled code, because they do not leave the virtual frame
    // in a spilled state.
    bool in_spilled_code_;
+
+  static InlineRuntimeLUT kInlineRuntimeLUT[];

    friend class VirtualFrame;
    friend class JumpTarget;

Modified: branches/bleeding_edge/src/x64/cpu-x64.cc
==============================================================================
--- branches/bleeding_edge/src/x64/cpu-x64.cc   (original)
+++ branches/bleeding_edge/src/x64/cpu-x64.cc   Tue May 12 03:33:40 2009
@@ -25,3 +25,41 @@
  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+// CPU specific code for x64 independent of OS goes here.
+
+#include "v8.h"
+
+#include "cpu.h"
+#include "macro-assembler.h"
+
+namespace v8 { namespace internal {
+
+void CPU::Setup() {
+  CpuFeatures::Probe();
+}
+
+
+void CPU::FlushICache(void* start, size_t size) {
+  // No need to flush the instruction cache on Intel. On Intel instruction
+  // cache flushing is only necessary when multiple cores running the same
+  // code simultaneously. V8 (and JavaScript) is single threaded and when  
code
+  // is patched on an intel CPU the core performing the patching will have  
its
+  // own instruction cache updated automatically.
+
+  // If flushing of the instruction cache becomes necessary Windows has the
+  // API function FlushInstructionCache.
+}
+
+
+void CPU::DebugBreak() {
+#ifdef _MSC_VER
+  // To avoid Visual Studio runtime support the following code can be used
+  // instead
+  // __asm { int 3 }
+  __debugbreak();
+#else
+  asm("int $3");
+#endif
+}
+
+} }  // namespace v8::internal

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to