OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 9530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9541 CONVERT_ARG_CHECKED(Object, obj, 0); | 9541 CONVERT_ARG_CHECKED(Object, obj, 0); |
9542 PrintTransition(isolate, obj); | 9542 PrintTransition(isolate, obj); |
9543 return obj; // return TOS | 9543 return obj; // return TOS |
9544 } | 9544 } |
9545 | 9545 |
9546 | 9546 |
9547 RUNTIME_FUNCTION(Runtime_DebugPrint) { | 9547 RUNTIME_FUNCTION(Runtime_DebugPrint) { |
9548 SealHandleScope shs(isolate); | 9548 SealHandleScope shs(isolate); |
9549 ASSERT(args.length() == 1); | 9549 ASSERT(args.length() == 1); |
9550 | 9550 |
| 9551 OFStream os(stdout); |
9551 #ifdef DEBUG | 9552 #ifdef DEBUG |
9552 if (args[0]->IsString()) { | 9553 if (args[0]->IsString()) { |
9553 // If we have a string, assume it's a code "marker" | 9554 // If we have a string, assume it's a code "marker" |
9554 // and print some interesting cpu debugging info. | 9555 // and print some interesting cpu debugging info. |
9555 JavaScriptFrameIterator it(isolate); | 9556 JavaScriptFrameIterator it(isolate); |
9556 JavaScriptFrame* frame = it.frame(); | 9557 JavaScriptFrame* frame = it.frame(); |
9557 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 9558 os << "fp = " << frame->fp() << ", sp = " << frame->sp() |
9558 frame->fp(), frame->sp(), frame->caller_sp()); | 9559 << ", caller_sp = " << frame->caller_sp() << ": "; |
9559 } else { | 9560 } else { |
9560 PrintF("DebugPrint: "); | 9561 os << "DebugPrint: "; |
9561 } | 9562 } |
9562 args[0]->Print(); | 9563 args[0]->Print(os); |
9563 if (args[0]->IsHeapObject()) { | 9564 if (args[0]->IsHeapObject()) { |
9564 PrintF("\n"); | 9565 os << "\n"; |
9565 HeapObject::cast(args[0])->map()->Print(); | 9566 HeapObject::cast(args[0])->map()->Print(os); |
9566 } | 9567 } |
9567 #else | 9568 #else |
9568 // ShortPrint is available in release mode. Print is not. | 9569 // ShortPrint is available in release mode. Print is not. |
9569 args[0]->ShortPrint(); | 9570 os << Brief(args[0]); |
9570 #endif | 9571 #endif |
9571 PrintF("\n"); | 9572 os << endl; |
9572 Flush(); | |
9573 | 9573 |
9574 return args[0]; // return TOS | 9574 return args[0]; // return TOS |
9575 } | 9575 } |
9576 | 9576 |
9577 | 9577 |
9578 RUNTIME_FUNCTION(Runtime_DebugTrace) { | 9578 RUNTIME_FUNCTION(Runtime_DebugTrace) { |
9579 SealHandleScope shs(isolate); | 9579 SealHandleScope shs(isolate); |
9580 ASSERT(args.length() == 0); | 9580 ASSERT(args.length() == 0); |
9581 isolate->PrintStack(stdout); | 9581 isolate->PrintStack(stdout); |
9582 return isolate->heap()->undefined_value(); | 9582 return isolate->heap()->undefined_value(); |
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12109 } else if (nested_scope_chain_.last()->HasContext()) { | 12109 } else if (nested_scope_chain_.last()->HasContext()) { |
12110 return context_; | 12110 return context_; |
12111 } else { | 12111 } else { |
12112 return Handle<Context>(); | 12112 return Handle<Context>(); |
12113 } | 12113 } |
12114 } | 12114 } |
12115 | 12115 |
12116 #ifdef DEBUG | 12116 #ifdef DEBUG |
12117 // Debug print of the content of the current scope. | 12117 // Debug print of the content of the current scope. |
12118 void DebugPrint() { | 12118 void DebugPrint() { |
| 12119 OFStream os(stdout); |
12119 ASSERT(!failed_); | 12120 ASSERT(!failed_); |
12120 switch (Type()) { | 12121 switch (Type()) { |
12121 case ScopeIterator::ScopeTypeGlobal: | 12122 case ScopeIterator::ScopeTypeGlobal: |
12122 PrintF("Global:\n"); | 12123 os << "Global:\n"; |
12123 CurrentContext()->Print(); | 12124 CurrentContext()->Print(os); |
12124 break; | 12125 break; |
12125 | 12126 |
12126 case ScopeIterator::ScopeTypeLocal: { | 12127 case ScopeIterator::ScopeTypeLocal: { |
12127 PrintF("Local:\n"); | 12128 os << "Local:\n"; |
12128 function_->shared()->scope_info()->Print(); | 12129 function_->shared()->scope_info()->Print(); |
12129 if (!CurrentContext().is_null()) { | 12130 if (!CurrentContext().is_null()) { |
12130 CurrentContext()->Print(); | 12131 CurrentContext()->Print(os); |
12131 if (CurrentContext()->has_extension()) { | 12132 if (CurrentContext()->has_extension()) { |
12132 Handle<Object> extension(CurrentContext()->extension(), isolate_); | 12133 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
12133 if (extension->IsJSContextExtensionObject()) { | 12134 if (extension->IsJSContextExtensionObject()) { |
12134 extension->Print(); | 12135 extension->Print(os); |
12135 } | 12136 } |
12136 } | 12137 } |
12137 } | 12138 } |
12138 break; | 12139 break; |
12139 } | 12140 } |
12140 | 12141 |
12141 case ScopeIterator::ScopeTypeWith: | 12142 case ScopeIterator::ScopeTypeWith: |
12142 PrintF("With:\n"); | 12143 os << "With:\n"; |
12143 CurrentContext()->extension()->Print(); | 12144 CurrentContext()->extension()->Print(os); |
12144 break; | 12145 break; |
12145 | 12146 |
12146 case ScopeIterator::ScopeTypeCatch: | 12147 case ScopeIterator::ScopeTypeCatch: |
12147 PrintF("Catch:\n"); | 12148 os << "Catch:\n"; |
12148 CurrentContext()->extension()->Print(); | 12149 CurrentContext()->extension()->Print(os); |
12149 CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(); | 12150 CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(os); |
12150 break; | 12151 break; |
12151 | 12152 |
12152 case ScopeIterator::ScopeTypeClosure: | 12153 case ScopeIterator::ScopeTypeClosure: |
12153 PrintF("Closure:\n"); | 12154 os << "Closure:\n"; |
12154 CurrentContext()->Print(); | 12155 CurrentContext()->Print(os); |
12155 if (CurrentContext()->has_extension()) { | 12156 if (CurrentContext()->has_extension()) { |
12156 Handle<Object> extension(CurrentContext()->extension(), isolate_); | 12157 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
12157 if (extension->IsJSContextExtensionObject()) { | 12158 if (extension->IsJSContextExtensionObject()) { |
12158 extension->Print(); | 12159 extension->Print(os); |
12159 } | 12160 } |
12160 } | 12161 } |
12161 break; | 12162 break; |
12162 | 12163 |
12163 default: | 12164 default: |
12164 UNREACHABLE(); | 12165 UNREACHABLE(); |
12165 } | 12166 } |
12166 PrintF("\n"); | 12167 PrintF("\n"); |
12167 } | 12168 } |
12168 #endif | 12169 #endif |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13257 | 13258 |
13258 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { | 13259 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { |
13259 HandleScope scope(isolate); | 13260 HandleScope scope(isolate); |
13260 #ifdef DEBUG | 13261 #ifdef DEBUG |
13261 ASSERT(args.length() == 1); | 13262 ASSERT(args.length() == 1); |
13262 // Get the function and make sure it is compiled. | 13263 // Get the function and make sure it is compiled. |
13263 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13264 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
13264 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13265 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
13265 return isolate->heap()->exception(); | 13266 return isolate->heap()->exception(); |
13266 } | 13267 } |
13267 func->code()->PrintLn(); | 13268 OFStream os(stdout); |
| 13269 func->code()->Print(os); |
| 13270 os << endl; |
13268 #endif // DEBUG | 13271 #endif // DEBUG |
13269 return isolate->heap()->undefined_value(); | 13272 return isolate->heap()->undefined_value(); |
13270 } | 13273 } |
13271 | 13274 |
13272 | 13275 |
13273 RUNTIME_FUNCTION(Runtime_DebugDisassembleConstructor) { | 13276 RUNTIME_FUNCTION(Runtime_DebugDisassembleConstructor) { |
13274 HandleScope scope(isolate); | 13277 HandleScope scope(isolate); |
13275 #ifdef DEBUG | 13278 #ifdef DEBUG |
13276 ASSERT(args.length() == 1); | 13279 ASSERT(args.length() == 1); |
13277 // Get the function and make sure it is compiled. | 13280 // Get the function and make sure it is compiled. |
13278 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13281 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
13279 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13282 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
13280 return isolate->heap()->exception(); | 13283 return isolate->heap()->exception(); |
13281 } | 13284 } |
13282 func->shared()->construct_stub()->PrintLn(); | 13285 OFStream os(stdout); |
| 13286 func->shared()->construct_stub()->Print(os); |
| 13287 os << endl; |
13283 #endif // DEBUG | 13288 #endif // DEBUG |
13284 return isolate->heap()->undefined_value(); | 13289 return isolate->heap()->undefined_value(); |
13285 } | 13290 } |
13286 | 13291 |
13287 | 13292 |
13288 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { | 13293 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { |
13289 SealHandleScope shs(isolate); | 13294 SealHandleScope shs(isolate); |
13290 ASSERT(args.length() == 1); | 13295 ASSERT(args.length() == 1); |
13291 | 13296 |
13292 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 13297 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15112 } | 15117 } |
15113 return NULL; | 15118 return NULL; |
15114 } | 15119 } |
15115 | 15120 |
15116 | 15121 |
15117 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15122 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15118 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15123 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15119 } | 15124 } |
15120 | 15125 |
15121 } } // namespace v8::internal | 15126 } } // namespace v8::internal |
OLD | NEW |