| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (!Compiler::Compile(func, KEEP_EXCEPTION)) { | 401 if (!Compiler::Compile(func, KEEP_EXCEPTION)) { |
| 402 return isolate->heap()->exception(); | 402 return isolate->heap()->exception(); |
| 403 } | 403 } |
| 404 OFStream os(stdout); | 404 OFStream os(stdout); |
| 405 func->code()->Print(os); | 405 func->code()->Print(os); |
| 406 os << std::endl; | 406 os << std::endl; |
| 407 #endif // DEBUG | 407 #endif // DEBUG |
| 408 return isolate->heap()->undefined_value(); | 408 return isolate->heap()->undefined_value(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 namespace { |
| 411 | 412 |
| 412 static int StackSize(Isolate* isolate) { | 413 int StackSize(Isolate* isolate) { |
| 413 int n = 0; | 414 int n = 0; |
| 414 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; | 415 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
| 415 return n; | 416 return n; |
| 416 } | 417 } |
| 417 | 418 |
| 418 | 419 void PrintIndentation(Isolate* isolate) { |
| 419 static void PrintTransition(Isolate* isolate, Object* result) { | 420 const int nmax = 80; |
| 420 // indentation | 421 int n = StackSize(isolate); |
| 421 { | 422 if (n <= nmax) { |
| 422 const int nmax = 80; | 423 PrintF("%4d:%*s", n, n, ""); |
| 423 int n = StackSize(isolate); | |
| 424 if (n <= nmax) | |
| 425 PrintF("%4d:%*s", n, n, ""); | |
| 426 else | |
| 427 PrintF("%4d:%*s", n, nmax, "..."); | |
| 428 } | |
| 429 | |
| 430 if (result == NULL) { | |
| 431 JavaScriptFrame::PrintTop(isolate, stdout, true, false); | |
| 432 PrintF(" {\n"); | |
| 433 } else { | 424 } else { |
| 434 // function result | 425 PrintF("%4d:%*s", n, nmax, "..."); |
| 435 PrintF("} -> "); | |
| 436 result->ShortPrint(); | |
| 437 PrintF("\n"); | |
| 438 } | 426 } |
| 439 } | 427 } |
| 440 | 428 |
| 429 } // namespace |
| 441 | 430 |
| 442 RUNTIME_FUNCTION(Runtime_TraceEnter) { | 431 RUNTIME_FUNCTION(Runtime_TraceEnter) { |
| 443 SealHandleScope shs(isolate); | 432 SealHandleScope shs(isolate); |
| 444 DCHECK(args.length() == 0); | 433 DCHECK_EQ(0, args.length()); |
| 445 PrintTransition(isolate, NULL); | 434 PrintIndentation(isolate); |
| 435 JavaScriptFrame::PrintTop(isolate, stdout, true, false); |
| 436 PrintF(" {\n"); |
| 446 return isolate->heap()->undefined_value(); | 437 return isolate->heap()->undefined_value(); |
| 447 } | 438 } |
| 448 | 439 |
| 449 | 440 |
| 450 RUNTIME_FUNCTION(Runtime_TraceExit) { | 441 RUNTIME_FUNCTION(Runtime_TraceExit) { |
| 451 SealHandleScope shs(isolate); | 442 SealHandleScope shs(isolate); |
| 452 DCHECK(args.length() == 1); | 443 DCHECK_EQ(1, args.length()); |
| 453 CONVERT_ARG_CHECKED(Object, obj, 0); | 444 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 454 PrintTransition(isolate, obj); | 445 PrintIndentation(isolate); |
| 446 PrintF("} -> "); |
| 447 obj->ShortPrint(); |
| 448 PrintF("\n"); |
| 455 return obj; // return TOS | 449 return obj; // return TOS |
| 456 } | 450 } |
| 457 | 451 |
| 452 RUNTIME_FUNCTION(Runtime_TraceTailCall) { |
| 453 SealHandleScope shs(isolate); |
| 454 DCHECK_EQ(0, args.length()); |
| 455 PrintIndentation(isolate); |
| 456 PrintF("} -> tail call ->\n"); |
| 457 return isolate->heap()->undefined_value(); |
| 458 } |
| 458 | 459 |
| 459 RUNTIME_FUNCTION(Runtime_HaveSameMap) { | 460 RUNTIME_FUNCTION(Runtime_HaveSameMap) { |
| 460 SealHandleScope shs(isolate); | 461 SealHandleScope shs(isolate); |
| 461 DCHECK(args.length() == 2); | 462 DCHECK(args.length() == 2); |
| 462 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 463 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
| 463 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 464 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
| 464 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 465 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
| 465 } | 466 } |
| 466 | 467 |
| 467 | 468 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 497 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ | 498 RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \ |
| 498 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 499 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 499 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | 500 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
| 500 } | 501 } |
| 501 | 502 |
| 502 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 503 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 503 | 504 |
| 504 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 505 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 505 } // namespace internal | 506 } // namespace internal |
| 506 } // namespace v8 | 507 } // namespace v8 |
| OLD | NEW |