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 int64_t low_bits = *reinterpret_cast<uint64_t*>(*args[0]) >> 32; | 137 int64_t low_bits, high_bits; |
138 int64_t high_bits = *reinterpret_cast<uint64_t*>(*args[1]); | 138 if (v8::internal::kSmiValueSize == 32) { |
| 139 low_bits = *reinterpret_cast<uint64_t*>(*args[0]) >> 32; |
| 140 high_bits = *reinterpret_cast<uint64_t*>(*args[1]); |
| 141 } else { |
| 142 ASSERT(v8::internal::kSmiValueSize == 31); |
| 143 // Low 33 bits ([32, 0]), the least two bits are zero. |
| 144 low_bits = ((*reinterpret_cast<uint64_t*>(*args[0])) & 0xffffffff) << 1; |
| 145 // High 32 bits ([63, 32]), 32th bit has been set by low_bits. |
| 146 high_bits = *reinterpret_cast<uint64_t*>(*args[1]) << 32; |
| 147 } |
139 Address fp = reinterpret_cast<Address>(high_bits | low_bits); | 148 Address fp = reinterpret_cast<Address>(high_bits | low_bits); |
140 #else | 149 #else |
141 #error Host architecture is neither 32-bit nor 64-bit. | 150 #error Host architecture is neither 32-bit nor 64-bit. |
142 #endif | 151 #endif |
143 printf("Trace: %p\n", fp); | 152 printf("Trace: %p\n", fp); |
144 return fp; | 153 return fp; |
145 } | 154 } |
146 | 155 |
147 | 156 |
148 void TraceExtension::Trace(const v8::FunctionCallbackInfo<v8::Value>& args) { | 157 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()); | 215 CHECK(frame_iterator.frame()->is_construct()); |
207 frame_iterator.Advance(); | 216 frame_iterator.Advance(); |
208 i::StackFrame* calling_frame = frame_iterator.frame(); | 217 i::StackFrame* calling_frame = frame_iterator.frame(); |
209 CHECK(calling_frame->is_java_script()); | 218 CHECK(calling_frame->is_java_script()); |
210 | 219 |
211 #if defined(V8_HOST_ARCH_32_BIT) | 220 #if defined(V8_HOST_ARCH_32_BIT) |
212 int32_t low_bits = reinterpret_cast<int32_t>(calling_frame->fp()); | 221 int32_t low_bits = reinterpret_cast<int32_t>(calling_frame->fp()); |
213 args.This()->Set(v8_str("low_bits"), v8_num(low_bits >> 1)); | 222 args.This()->Set(v8_str("low_bits"), v8_num(low_bits >> 1)); |
214 #elif defined(V8_HOST_ARCH_64_BIT) | 223 #elif defined(V8_HOST_ARCH_64_BIT) |
215 uint64_t fp = reinterpret_cast<uint64_t>(calling_frame->fp()); | 224 uint64_t fp = reinterpret_cast<uint64_t>(calling_frame->fp()); |
216 int32_t low_bits = static_cast<int32_t>(fp & 0xffffffff); | 225 int32_t low_bits, high_bits; |
217 int32_t high_bits = static_cast<int32_t>(fp >> 32); | 226 if (v8::internal::kSmiValueSize == 32) { |
| 227 low_bits = static_cast<int32_t>(fp & 0xffffffff); |
| 228 high_bits = static_cast<int32_t>(fp >> 32); |
| 229 } else { |
| 230 ASSERT(v8::internal::kSmiValueSize == 31); |
| 231 // Middle 31-bits ([32, 2]), the least two bits are always 0 for FP. |
| 232 low_bits = static_cast<int32_t>((fp >> 2) & 0xffffffff); |
| 233 // High 31-bits ([63, 33]). |
| 234 high_bits = static_cast<int32_t>(fp >> 33); |
| 235 } |
218 args.This()->Set(v8_str("low_bits"), v8_num(low_bits)); | 236 args.This()->Set(v8_str("low_bits"), v8_num(low_bits)); |
219 args.This()->Set(v8_str("high_bits"), v8_num(high_bits)); | 237 args.This()->Set(v8_str("high_bits"), v8_num(high_bits)); |
220 #else | 238 #else |
221 #error Host architecture is neither 32-bit nor 64-bit. | 239 #error Host architecture is neither 32-bit nor 64-bit. |
222 #endif | 240 #endif |
223 args.GetReturnValue().Set(args.This()); | 241 args.GetReturnValue().Set(args.This()); |
224 } | 242 } |
225 | 243 |
226 | 244 |
227 // Use the API to create a JSFunction object that calls the above C++ function. | 245 // 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); | 407 CcTest::InitializeVM(TRACE_EXTENSION); |
390 v8::HandleScope scope(CcTest::isolate()); | 408 v8::HandleScope scope(CcTest::isolate()); |
391 CHECK_EQ(0, GetJsEntrySp()); | 409 CHECK_EQ(0, GetJsEntrySp()); |
392 CompileRun("a = 1; b = a + 1;"); | 410 CompileRun("a = 1; b = a + 1;"); |
393 CHECK_EQ(0, GetJsEntrySp()); | 411 CHECK_EQ(0, GetJsEntrySp()); |
394 CompileRun("js_entry_sp();"); | 412 CompileRun("js_entry_sp();"); |
395 CHECK_EQ(0, GetJsEntrySp()); | 413 CHECK_EQ(0, GetJsEntrySp()); |
396 CompileRun("js_entry_sp_level2();"); | 414 CompileRun("js_entry_sp_level2();"); |
397 CHECK_EQ(0, GetJsEntrySp()); | 415 CHECK_EQ(0, GetJsEntrySp()); |
398 } | 416 } |
OLD | NEW |