| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { | 131 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 132 // Convert frame pointer from encoding as smis in the arguments to a pointer. | 132 // Convert frame pointer from encoding as smis in the arguments to a pointer. |
| 133 CHECK_EQ(2, args.Length()); // Ignore second argument on 32-bit platform. | 133 CHECK_EQ(2, args.Length()); // Ignore second argument on 32-bit platform. |
| 134 #if defined(V8_HOST_ARCH_32_BIT) | 134 #if defined(V8_HOST_ARCH_32_BIT) |
| 135 Address fp = *reinterpret_cast<Address*>(*args[0]); | 135 Address fp = *reinterpret_cast<Address*>(*args[0]); |
| 136 #elif defined(V8_HOST_ARCH_64_BIT) | 136 #elif defined(V8_HOST_ARCH_64_BIT) |
| 137 #if !V8_USE_31_BITS_SMI_VALUE |
| 137 int64_t low_bits = *reinterpret_cast<uint64_t*>(*args[0]) >> 32; | 138 int64_t low_bits = *reinterpret_cast<uint64_t*>(*args[0]) >> 32; |
| 138 int64_t high_bits = *reinterpret_cast<uint64_t*>(*args[1]); | 139 int64_t high_bits = *reinterpret_cast<uint64_t*>(*args[1]); |
| 140 #else |
| 141 // Low 33 bits ([32, 0]), the least two bits are zero. |
| 142 int64_t low_bits = ((*reinterpret_cast<uint64_t*>(*args[0])) & 0xffffffff) |
| 143 << 1; |
| 144 // High 32 bits ([63, 32]), 32th bit has been set by low_bits. |
| 145 int64_t high_bits = *reinterpret_cast<uint64_t*>(*args[1]) << 32; |
| 146 #endif |
| 139 Address fp = reinterpret_cast<Address>(high_bits | low_bits); | 147 Address fp = reinterpret_cast<Address>(high_bits | low_bits); |
| 140 #else | 148 #else |
| 141 #error Host architecture is neither 32-bit nor 64-bit. | 149 #error Host architecture is neither 32-bit nor 64-bit. |
| 142 #endif | 150 #endif |
| 143 printf("Trace: %p\n", fp); | 151 printf("Trace: %p\n", fp); |
| 144 return fp; | 152 return fp; |
| 145 } | 153 } |
| 146 | 154 |
| 147 | 155 |
| 148 void TraceExtension::Trace(const v8::FunctionCallbackInfo<v8::Value>& args) { | 156 void TraceExtension::Trace(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 CHECK(frame_iterator.frame()->is_construct()); | 214 CHECK(frame_iterator.frame()->is_construct()); |
| 207 frame_iterator.Advance(); | 215 frame_iterator.Advance(); |
| 208 i::StackFrame* calling_frame = frame_iterator.frame(); | 216 i::StackFrame* calling_frame = frame_iterator.frame(); |
| 209 CHECK(calling_frame->is_java_script()); | 217 CHECK(calling_frame->is_java_script()); |
| 210 | 218 |
| 211 #if defined(V8_HOST_ARCH_32_BIT) | 219 #if defined(V8_HOST_ARCH_32_BIT) |
| 212 int32_t low_bits = reinterpret_cast<int32_t>(calling_frame->fp()); | 220 int32_t low_bits = reinterpret_cast<int32_t>(calling_frame->fp()); |
| 213 args.This()->Set(v8_str("low_bits"), v8_num(low_bits >> 1)); | 221 args.This()->Set(v8_str("low_bits"), v8_num(low_bits >> 1)); |
| 214 #elif defined(V8_HOST_ARCH_64_BIT) | 222 #elif defined(V8_HOST_ARCH_64_BIT) |
| 215 uint64_t fp = reinterpret_cast<uint64_t>(calling_frame->fp()); | 223 uint64_t fp = reinterpret_cast<uint64_t>(calling_frame->fp()); |
| 224 #if !V8_USE_31_BITS_SMI_VALUE |
| 216 int32_t low_bits = static_cast<int32_t>(fp & 0xffffffff); | 225 int32_t low_bits = static_cast<int32_t>(fp & 0xffffffff); |
| 217 int32_t high_bits = static_cast<int32_t>(fp >> 32); | 226 int32_t high_bits = static_cast<int32_t>(fp >> 32); |
| 227 #else |
| 228 // Middle 31-bits ([32, 2]), the least two bits are always 0 for FP. |
| 229 int32_t low_bits = static_cast<int32_t>((fp >> 2) & 0xffffffff); |
| 230 // High 31-bits ([63, 33]). |
| 231 int32_t high_bits = static_cast<int32_t>(fp >> 33); |
| 232 #endif |
| 218 args.This()->Set(v8_str("low_bits"), v8_num(low_bits)); | 233 args.This()->Set(v8_str("low_bits"), v8_num(low_bits)); |
| 219 args.This()->Set(v8_str("high_bits"), v8_num(high_bits)); | 234 args.This()->Set(v8_str("high_bits"), v8_num(high_bits)); |
| 220 #else | 235 #else |
| 221 #error Host architecture is neither 32-bit nor 64-bit. | 236 #error Host architecture is neither 32-bit nor 64-bit. |
| 222 #endif | 237 #endif |
| 223 args.GetReturnValue().Set(args.This()); | 238 args.GetReturnValue().Set(args.This()); |
| 224 } | 239 } |
| 225 | 240 |
| 226 | 241 |
| 227 // Use the API to create a JSFunction object that calls the above C++ function. | 242 // Use the API to create a JSFunction object that calls the above C++ function. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 CcTest::InitializeVM(TRACE_EXTENSION); | 404 CcTest::InitializeVM(TRACE_EXTENSION); |
| 390 v8::HandleScope scope(CcTest::isolate()); | 405 v8::HandleScope scope(CcTest::isolate()); |
| 391 CHECK_EQ(0, GetJsEntrySp()); | 406 CHECK_EQ(0, GetJsEntrySp()); |
| 392 CompileRun("a = 1; b = a + 1;"); | 407 CompileRun("a = 1; b = a + 1;"); |
| 393 CHECK_EQ(0, GetJsEntrySp()); | 408 CHECK_EQ(0, GetJsEntrySp()); |
| 394 CompileRun("js_entry_sp();"); | 409 CompileRun("js_entry_sp();"); |
| 395 CHECK_EQ(0, GetJsEntrySp()); | 410 CHECK_EQ(0, GetJsEntrySp()); |
| 396 CompileRun("js_entry_sp_level2();"); | 411 CompileRun("js_entry_sp_level2();"); |
| 397 CHECK_EQ(0, GetJsEntrySp()); | 412 CHECK_EQ(0, GetJsEntrySp()); |
| 398 } | 413 } |
| OLD | NEW |