OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/full-codegen.h" | 9 #include "src/full-codegen.h" |
10 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 RUNTIME_FUNCTION(Runtime_GetV8Version) { | 296 RUNTIME_FUNCTION(Runtime_GetV8Version) { |
297 HandleScope scope(isolate); | 297 HandleScope scope(isolate); |
298 DCHECK(args.length() == 0); | 298 DCHECK(args.length() == 0); |
299 | 299 |
300 const char* version_string = v8::V8::GetVersion(); | 300 const char* version_string = v8::V8::GetVersion(); |
301 | 301 |
302 return *isolate->factory()->NewStringFromAsciiChecked(version_string); | 302 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
303 } | 303 } |
304 | 304 |
305 | 305 |
| 306 static int StackSize(Isolate* isolate) { |
| 307 int n = 0; |
| 308 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
| 309 return n; |
| 310 } |
| 311 |
| 312 |
| 313 static void PrintTransition(Isolate* isolate, Object* result) { |
| 314 // indentation |
| 315 { |
| 316 const int nmax = 80; |
| 317 int n = StackSize(isolate); |
| 318 if (n <= nmax) |
| 319 PrintF("%4d:%*s", n, n, ""); |
| 320 else |
| 321 PrintF("%4d:%*s", n, nmax, "..."); |
| 322 } |
| 323 |
| 324 if (result == NULL) { |
| 325 JavaScriptFrame::PrintTop(isolate, stdout, true, false); |
| 326 PrintF(" {\n"); |
| 327 } else { |
| 328 // function result |
| 329 PrintF("} -> "); |
| 330 result->ShortPrint(); |
| 331 PrintF("\n"); |
| 332 } |
| 333 } |
| 334 |
| 335 |
| 336 RUNTIME_FUNCTION(Runtime_TraceEnter) { |
| 337 SealHandleScope shs(isolate); |
| 338 DCHECK(args.length() == 0); |
| 339 PrintTransition(isolate, NULL); |
| 340 return isolate->heap()->undefined_value(); |
| 341 } |
| 342 |
| 343 |
| 344 RUNTIME_FUNCTION(Runtime_TraceExit) { |
| 345 SealHandleScope shs(isolate); |
| 346 DCHECK(args.length() == 1); |
| 347 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 348 PrintTransition(isolate, obj); |
| 349 return obj; // return TOS |
| 350 } |
| 351 |
| 352 |
306 #ifdef DEBUG | 353 #ifdef DEBUG |
307 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 354 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
308 // Exclude the code in release mode. | 355 // Exclude the code in release mode. |
309 RUNTIME_FUNCTION(Runtime_ListNatives) { | 356 RUNTIME_FUNCTION(Runtime_ListNatives) { |
310 HandleScope scope(isolate); | 357 HandleScope scope(isolate); |
311 DCHECK(args.length() == 0); | 358 DCHECK(args.length() == 0); |
312 #define COUNT_ENTRY(Name, argc, ressize) +1 | 359 #define COUNT_ENTRY(Name, argc, ressize) +1 |
313 int entry_count = | 360 int entry_count = |
314 0 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) INLINE_FUNCTION_LIST(COUNT_ENTRY) | 361 0 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) INLINE_FUNCTION_LIST(COUNT_ENTRY) |
315 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); | 362 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ | 438 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ |
392 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 439 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
393 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | 440 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
394 } | 441 } |
395 | 442 |
396 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 443 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
397 | 444 |
398 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 445 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
399 } | 446 } |
400 } // namespace v8::internal | 447 } // namespace v8::internal |
OLD | NEW |