OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 HashMap::Clear(); | 663 HashMap::Clear(); |
664 } | 664 } |
665 | 665 |
666 | 666 |
667 void ScriptCache::HandleWeakScript(v8::Isolate* isolate, | 667 void ScriptCache::HandleWeakScript(v8::Isolate* isolate, |
668 v8::Persistent<v8::Value>* obj, | 668 v8::Persistent<v8::Value>* obj, |
669 void* data) { | 669 void* data) { |
670 ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data); | 670 ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data); |
671 // Find the location of the global handle. | 671 // Find the location of the global handle. |
672 Script** location = | 672 Script** location = |
673 reinterpret_cast<Script**>(Utils::OpenHandle(**obj).location()); | 673 reinterpret_cast<Script**>(Utils::OpenPersistent(*obj).location()); |
674 ASSERT((*location)->IsScript()); | 674 ASSERT((*location)->IsScript()); |
675 | 675 |
676 // Remove the entry from the cache. | 676 // Remove the entry from the cache. |
677 int id = Smi::cast((*location)->id())->value(); | 677 int id = Smi::cast((*location)->id())->value(); |
678 script_cache->Remove(reinterpret_cast<void*>(id), Hash(id)); | 678 script_cache->Remove(reinterpret_cast<void*>(id), Hash(id)); |
679 script_cache->collected_scripts_.Add(id); | 679 script_cache->collected_scripts_.Add(id); |
680 | 680 |
681 // Clear the weak handle. | 681 // Clear the weak handle. |
682 obj->Dispose(isolate); | 682 obj->Dispose(isolate); |
683 } | 683 } |
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3059 v8::TryCatch try_catch; | 3059 v8::TryCatch try_catch; |
3060 | 3060 |
3061 // DebugCommandProcessor goes here. | 3061 // DebugCommandProcessor goes here. |
3062 v8::Local<v8::Object> cmd_processor; | 3062 v8::Local<v8::Object> cmd_processor; |
3063 { | 3063 { |
3064 v8::Local<v8::Object> api_exec_state = | 3064 v8::Local<v8::Object> api_exec_state = |
3065 v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state)); | 3065 v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state)); |
3066 v8::Local<v8::String> fun_name = | 3066 v8::Local<v8::String> fun_name = |
3067 v8::String::New("debugCommandProcessor"); | 3067 v8::String::New("debugCommandProcessor"); |
3068 v8::Local<v8::Function> fun = | 3068 v8::Local<v8::Function> fun = |
3069 v8::Function::Cast(*api_exec_state->Get(fun_name)); | 3069 v8::Local<v8::Function>::Cast(api_exec_state->Get(fun_name)); |
3070 | 3070 |
3071 v8::Handle<v8::Boolean> running = | 3071 v8::Handle<v8::Boolean> running = |
3072 auto_continue ? v8::True() : v8::False(); | 3072 auto_continue ? v8::True() : v8::False(); |
3073 static const int kArgc = 1; | 3073 static const int kArgc = 1; |
3074 v8::Handle<Value> argv[kArgc] = { running }; | 3074 v8::Handle<Value> argv[kArgc] = { running }; |
3075 cmd_processor = v8::Object::Cast(*fun->Call(api_exec_state, kArgc, argv)); | 3075 cmd_processor = v8::Local<v8::Object>::Cast( |
| 3076 fun->Call(api_exec_state, kArgc, argv)); |
3076 if (try_catch.HasCaught()) { | 3077 if (try_catch.HasCaught()) { |
3077 PrintLn(try_catch.Exception()); | 3078 PrintLn(try_catch.Exception()); |
3078 return; | 3079 return; |
3079 } | 3080 } |
3080 } | 3081 } |
3081 | 3082 |
3082 bool running = auto_continue; | 3083 bool running = auto_continue; |
3083 | 3084 |
3084 // Process requests from the debugger. | 3085 // Process requests from the debugger. |
3085 while (true) { | 3086 while (true) { |
(...skipping 19 matching lines...) Expand all Loading... |
3105 command.Dispose(); | 3106 command.Dispose(); |
3106 return; | 3107 return; |
3107 } | 3108 } |
3108 | 3109 |
3109 // Invoke JavaScript to process the debug request. | 3110 // Invoke JavaScript to process the debug request. |
3110 v8::Local<v8::String> fun_name; | 3111 v8::Local<v8::String> fun_name; |
3111 v8::Local<v8::Function> fun; | 3112 v8::Local<v8::Function> fun; |
3112 v8::Local<v8::Value> request; | 3113 v8::Local<v8::Value> request; |
3113 v8::TryCatch try_catch; | 3114 v8::TryCatch try_catch; |
3114 fun_name = v8::String::New("processDebugRequest"); | 3115 fun_name = v8::String::New("processDebugRequest"); |
3115 fun = v8::Function::Cast(*cmd_processor->Get(fun_name)); | 3116 fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name)); |
3116 | 3117 |
3117 request = v8::String::New(command.text().start(), | 3118 request = v8::String::New(command.text().start(), |
3118 command.text().length()); | 3119 command.text().length()); |
3119 static const int kArgc = 1; | 3120 static const int kArgc = 1; |
3120 v8::Handle<Value> argv[kArgc] = { request }; | 3121 v8::Handle<Value> argv[kArgc] = { request }; |
3121 v8::Local<v8::Value> response_val = fun->Call(cmd_processor, kArgc, argv); | 3122 v8::Local<v8::Value> response_val = fun->Call(cmd_processor, kArgc, argv); |
3122 | 3123 |
3123 // Get the response. | 3124 // Get the response. |
3124 v8::Local<v8::String> response; | 3125 v8::Local<v8::String> response; |
3125 if (!try_catch.HasCaught()) { | 3126 if (!try_catch.HasCaught()) { |
3126 // Get response string. | 3127 // Get response string. |
3127 if (!response_val->IsUndefined()) { | 3128 if (!response_val->IsUndefined()) { |
3128 response = v8::String::Cast(*response_val); | 3129 response = v8::Local<v8::String>::Cast(response_val); |
3129 } else { | 3130 } else { |
3130 response = v8::String::New(""); | 3131 response = v8::String::New(""); |
3131 } | 3132 } |
3132 | 3133 |
3133 // Log the JSON request/response. | 3134 // Log the JSON request/response. |
3134 if (FLAG_trace_debug_json) { | 3135 if (FLAG_trace_debug_json) { |
3135 PrintLn(request); | 3136 PrintLn(request); |
3136 PrintLn(response); | 3137 PrintLn(response); |
3137 } | 3138 } |
3138 | 3139 |
3139 // Get the running state. | 3140 // Get the running state. |
3140 fun_name = v8::String::New("isRunning"); | 3141 fun_name = v8::String::New("isRunning"); |
3141 fun = v8::Function::Cast(*cmd_processor->Get(fun_name)); | 3142 fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name)); |
3142 static const int kArgc = 1; | 3143 static const int kArgc = 1; |
3143 v8::Handle<Value> argv[kArgc] = { response }; | 3144 v8::Handle<Value> argv[kArgc] = { response }; |
3144 v8::Local<v8::Value> running_val = fun->Call(cmd_processor, kArgc, argv); | 3145 v8::Local<v8::Value> running_val = fun->Call(cmd_processor, kArgc, argv); |
3145 if (!try_catch.HasCaught()) { | 3146 if (!try_catch.HasCaught()) { |
3146 running = running_val->ToBoolean()->Value(); | 3147 running = running_val->ToBoolean()->Value(); |
3147 } | 3148 } |
3148 } else { | 3149 } else { |
3149 // In case of failure the result text is the exception text. | 3150 // In case of failure the result text is the exception text. |
3150 response = try_catch.Exception()->ToString(); | 3151 response = try_catch.Exception()->ToString(); |
3151 } | 3152 } |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 { | 3800 { |
3800 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3801 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3801 isolate_->debugger()->CallMessageDispatchHandler(); | 3802 isolate_->debugger()->CallMessageDispatchHandler(); |
3802 } | 3803 } |
3803 } | 3804 } |
3804 } | 3805 } |
3805 | 3806 |
3806 #endif // ENABLE_DEBUGGER_SUPPORT | 3807 #endif // ENABLE_DEBUGGER_SUPPORT |
3807 | 3808 |
3808 } } // namespace v8::internal | 3809 } } // namespace v8::internal |
OLD | NEW |