Reviewers: Lasse Reichstein, Description: Fix debug printing of pointers, and a keyed store with smi index error, in X64
Please review this at http://codereview.chromium.org/160452 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/string-stream.h M src/string-stream.cc M src/x64/ic-x64.cc M test/cctest/cctest.status Index: test/cctest/cctest.status =================================================================== --- test/cctest/cctest.status (revision 2600) +++ test/cctest/cctest.status (working copy) @@ -63,7 +63,6 @@ [ $arch == x64 ] -test-regexp/Graph: PASS || CRASH || FAIL test-decls/Present: CRASH || FAIL test-decls/Unknown: CRASH || FAIL test-decls/Appearing: CRASH || FAIL Index: src/string-stream.h =================================================================== --- src/string-stream.h (revision 2600) +++ src/string-stream.h (working copy) @@ -90,21 +90,12 @@ FmtElm(Handle<Object> value) : type_(HANDLE) { // NOLINT data_.u_handle_ = value.location(); } - FmtElm(void* value) : type_(INT) { // NOLINT -#if V8_HOST_ARCH_64_BIT - // TODO(x64): FmtElm needs to treat pointers as pointers, and not as - // ints. This will require adding a pointer type, etc. For now just - // hack it and truncate the pointer. - // http://code.google.com/p/v8/issues/detail?id=335 - data_.u_int_ = 0; - UNIMPLEMENTED(); -#else - data_.u_int_ = reinterpret_cast<int>(value); -#endif + FmtElm(void* value) : type_(POINTER) { // NOLINT + data_.u_pointer_ = value; } private: friend class StringStream; - enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE }; + enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE, POINTER }; Type type_; union { int u_int_; @@ -113,6 +104,7 @@ const Vector<const uc16>* u_lc_str_; Object* u_obj_; Object** u_handle_; + void* u_pointer_; } data_; }; Index: src/x64/ic-x64.cc =================================================================== --- src/x64/ic-x64.cc (revision 2600) +++ src/x64/ic-x64.cc (working copy) @@ -424,6 +424,9 @@ // Check that the key is a smi. __ testl(rbx, Immediate(kSmiTagMask)); __ j(not_zero, &slow); + // If it is a smi, make sure it is zero-extended, so it can be + // used as an index in a memory operand. + __ movl(rbx, rbx); // Clear the high bits of rbx. __ CmpInstanceType(rcx, JS_ARRAY_TYPE); __ j(equal, &array); @@ -434,7 +437,7 @@ // Object case: Check key against length in the elements array. // rax: value // rdx: JSObject - // rbx: index (as a smi) + // rbx: index (as a smi), zero-extended. __ movq(rcx, FieldOperand(rdx, JSObject::kElementsOffset)); // Check that the object is in fast mode (not dictionary). __ Cmp(FieldOperand(rcx, HeapObject::kMapOffset), Factory::fixed_array_map()); Index: src/string-stream.cc =================================================================== --- src/string-stream.cc (revision 2600) +++ src/string-stream.cc (working copy) @@ -153,7 +153,7 @@ } break; } - case 'i': case 'd': case 'u': case 'x': case 'c': case 'p': case 'X': { + case 'i': case 'd': case 'u': case 'x': case 'c': case 'X': { int value = current.data_.u_int_; EmbeddedVector<char, 24> formatted; int length = OS::SNPrintF(formatted, temp.start(), value); @@ -167,6 +167,13 @@ Add(formatted.start()); break; } + case 'p': { + void* value = current.data_.u_pointer_; + EmbeddedVector<char, 28> formatted; + OS::SNPrintF(formatted, temp.start(), value); + Add(formatted.start()); + break; + } default: UNREACHABLE(); break; --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
