Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 92 |
| 93 // --- D a t a t h a t i s s p e c i f i c t o a t h r e a d --- | 93 // --- D a t a t h a t i s s p e c i f i c t o a t h r e a d --- |
| 94 | 94 |
| 95 | 95 |
| 96 static i::HandleScopeImplementer thread_local; | 96 static i::HandleScopeImplementer thread_local; |
| 97 | 97 |
| 98 | 98 |
| 99 // --- E x c e p t i o n B e h a v i o r --- | 99 // --- E x c e p t i o n B e h a v i o r --- |
| 100 | 100 |
| 101 | 101 |
| 102 static bool has_shut_down = false; | |
| 103 static FatalErrorCallback exception_behavior = NULL; | 102 static FatalErrorCallback exception_behavior = NULL; |
| 104 | 103 |
| 105 | 104 |
| 106 static void DefaultFatalErrorHandler(const char* location, | 105 static void DefaultFatalErrorHandler(const char* location, |
| 107 const char* message) { | 106 const char* message) { |
| 108 ENTER_V8; | 107 ENTER_V8; |
| 109 API_Fatal(location, message); | 108 API_Fatal(location, message); |
| 110 } | 109 } |
| 111 | 110 |
| 112 | 111 |
| 113 | 112 |
| 114 static FatalErrorCallback& GetFatalErrorHandler() { | 113 static FatalErrorCallback& GetFatalErrorHandler() { |
| 115 if (exception_behavior == NULL) { | 114 if (exception_behavior == NULL) { |
| 116 exception_behavior = DefaultFatalErrorHandler; | 115 exception_behavior = DefaultFatalErrorHandler; |
| 117 } | 116 } |
| 118 return exception_behavior; | 117 return exception_behavior; |
| 119 } | 118 } |
| 120 | 119 |
| 121 | 120 |
| 122 | 121 |
| 123 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. | 122 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
| 124 // The default fatal error handler is called and execution is stopped. | 123 // The default fatal error handler is called and execution is stopped. |
| 125 void i::V8::FatalProcessOutOfMemory(const char* location) { | 124 void i::V8::FatalProcessOutOfMemory(const char* location) { |
| 126 has_shut_down = true; | 125 i::V8::SetFatalError(); |
| 127 FatalErrorCallback callback = GetFatalErrorHandler(); | 126 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 128 { | 127 { |
| 129 LEAVE_V8; | 128 LEAVE_V8; |
| 130 callback(location, "Allocation failed - process out of memory"); | 129 callback(location, "Allocation failed - process out of memory"); |
| 131 } | 130 } |
| 132 // If the callback returns, we stop execution. | 131 // If the callback returns, we stop execution. |
| 133 UNREACHABLE(); | 132 UNREACHABLE(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 | 135 |
| 137 void V8::SetFatalErrorHandler(FatalErrorCallback that) { | 136 void V8::SetFatalErrorHandler(FatalErrorCallback that) { |
| 138 exception_behavior = that; | 137 exception_behavior = that; |
| 139 } | 138 } |
| 140 | 139 |
| 141 | 140 |
| 142 bool Utils::ReportApiFailure(const char* location, const char* message) { | 141 bool Utils::ReportApiFailure(const char* location, const char* message) { |
| 143 FatalErrorCallback callback = GetFatalErrorHandler(); | 142 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 144 callback(location, message); | 143 callback(location, message); |
| 145 has_shut_down = true; | 144 i::V8::SetFatalError(); |
| 146 return false; | 145 return false; |
| 147 } | 146 } |
| 148 | 147 |
| 149 | 148 |
| 150 bool V8::IsDead() { | 149 bool V8::IsDead() { |
| 151 return has_shut_down; | 150 return i::V8::IsDead(); |
| 152 } | 151 } |
| 153 | 152 |
| 154 | 153 |
| 155 static inline bool ApiCheck(bool condition, | 154 static inline bool ApiCheck(bool condition, |
| 156 const char* location, | 155 const char* location, |
| 157 const char* message) { | 156 const char* message) { |
| 158 return condition ? true : Utils::ReportApiFailure(location, message); | 157 return condition ? true : Utils::ReportApiFailure(location, message); |
| 159 } | 158 } |
| 160 | 159 |
| 161 | 160 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 179 * entry to all methods that touch anything in the heap, except destructors | 178 * entry to all methods that touch anything in the heap, except destructors |
| 180 * which you sometimes can't avoid calling after the vm has crashed. Functions | 179 * which you sometimes can't avoid calling after the vm has crashed. Functions |
| 181 * that call EnsureInitialized or ON_BAILOUT don't have to also call | 180 * that call EnsureInitialized or ON_BAILOUT don't have to also call |
| 182 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you | 181 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you |
| 183 * can arrange to return if the VM is dead. This is needed to ensure that no VM | 182 * can arrange to return if the VM is dead. This is needed to ensure that no VM |
| 184 * heap allocations are attempted on a dead VM. EnsureInitialized has the | 183 * heap allocations are attempted on a dead VM. EnsureInitialized has the |
| 185 * advantage over ON_BAILOUT that it actually initializes the VM if this has not | 184 * advantage over ON_BAILOUT that it actually initializes the VM if this has not |
| 186 * yet been done. | 185 * yet been done. |
| 187 */ | 186 */ |
| 188 static inline bool IsDeadCheck(const char* location) { | 187 static inline bool IsDeadCheck(const char* location) { |
| 189 return has_shut_down ? ReportV8Dead(location) : false; | 188 return !i::V8::IsRunning() |
| 189 && i::V8::IsDead() ? ReportV8Dead(location) : false; | |
| 190 } | 190 } |
| 191 | 191 |
| 192 | 192 |
| 193 static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) { | 193 static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) { |
| 194 return obj.IsEmpty() ? ReportEmptyHandle(location) : false; | 194 return obj.IsEmpty() ? ReportEmptyHandle(location) : false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 | 197 |
| 198 static inline bool EmptyCheck(const char* location, const v8::Data* obj) { | 198 static inline bool EmptyCheck(const char* location, const v8::Data* obj) { |
| 199 return (obj == 0) ? ReportEmptyHandle(location) : false; | 199 return (obj == 0) ? ReportEmptyHandle(location) : false; |
| 200 } | 200 } |
| 201 | 201 |
| 202 // --- S t a t i c s --- | 202 // --- S t a t i c s --- |
| 203 | 203 |
| 204 | 204 |
| 205 static i::StringInputBuffer write_input_buffer; | 205 static i::StringInputBuffer write_input_buffer; |
| 206 | 206 |
| 207 | 207 |
| 208 static void EnsureInitialized(const char* location) { | 208 static inline bool EnsureInitialized(const char* location) { |
| 209 if (IsDeadCheck(location)) return; | 209 if (i::V8::IsRunning()) { |
| 210 ApiCheck(v8::V8::Initialize(), location, "Error initializing V8"); | 210 return true; |
| 211 } | |
| 212 return ApiCheck(v8::V8::Initialize(), location, "Error initializing V8"); | |
|
iposva
2009/05/07 23:04:06
Thinking about it further it might be helpful to c
| |
| 211 } | 213 } |
| 212 | 214 |
| 213 | 215 |
| 214 ImplementationUtilities::HandleScopeData* | 216 ImplementationUtilities::HandleScopeData* |
| 215 ImplementationUtilities::CurrentHandleScope() { | 217 ImplementationUtilities::CurrentHandleScope() { |
| 216 return &i::HandleScope::current_; | 218 return &i::HandleScope::current_; |
| 217 } | 219 } |
| 218 | 220 |
| 219 | 221 |
| 220 #ifdef DEBUG | 222 #ifdef DEBUG |
| 221 void ImplementationUtilities::ZapHandleRange(void** begin, void** end) { | 223 void ImplementationUtilities::ZapHandleRange(void** begin, void** end) { |
| 222 i::HandleScope::ZapRange(begin, end); | 224 i::HandleScope::ZapRange(begin, end); |
| 223 } | 225 } |
| 224 #endif | 226 #endif |
| 225 | 227 |
| 226 | 228 |
| 227 v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() { | 229 v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() { |
| 228 if (IsDeadCheck("v8::Undefined()")) return v8::Handle<v8::Primitive>(); | 230 if (!EnsureInitialized("v8::Undefined()")) return v8::Handle<v8::Primitive>(); |
| 229 EnsureInitialized("v8::Undefined()"); | |
| 230 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::undefined_value())); | 231 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::undefined_value())); |
| 231 } | 232 } |
| 232 | 233 |
| 233 | 234 |
| 234 v8::Handle<v8::Primitive> ImplementationUtilities::Null() { | 235 v8::Handle<v8::Primitive> ImplementationUtilities::Null() { |
| 235 if (IsDeadCheck("v8::Null()")) return v8::Handle<v8::Primitive>(); | 236 if (!EnsureInitialized("v8::Null()")) return v8::Handle<v8::Primitive>(); |
| 236 EnsureInitialized("v8::Null()"); | |
| 237 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::null_value())); | 237 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::null_value())); |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 v8::Handle<v8::Boolean> ImplementationUtilities::True() { | 241 v8::Handle<v8::Boolean> ImplementationUtilities::True() { |
| 242 if (IsDeadCheck("v8::True()")) return v8::Handle<v8::Boolean>(); | 242 if (!EnsureInitialized("v8::True()")) return v8::Handle<v8::Boolean>(); |
| 243 EnsureInitialized("v8::True()"); | |
| 244 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::true_value())); | 243 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::true_value())); |
| 245 } | 244 } |
| 246 | 245 |
| 247 | 246 |
| 248 v8::Handle<v8::Boolean> ImplementationUtilities::False() { | 247 v8::Handle<v8::Boolean> ImplementationUtilities::False() { |
| 249 if (IsDeadCheck("v8::False()")) return v8::Handle<v8::Boolean>(); | 248 if (!EnsureInitialized("v8::False()")) return v8::Handle<v8::Boolean>(); |
| 250 EnsureInitialized("v8::False()"); | |
| 251 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::false_value())); | 249 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::false_value())); |
| 252 } | 250 } |
| 253 | 251 |
| 254 | 252 |
| 255 void V8::SetFlagsFromString(const char* str, int length) { | 253 void V8::SetFlagsFromString(const char* str, int length) { |
| 256 i::FlagList::SetFlagsFromString(str, length); | 254 i::FlagList::SetFlagsFromString(str, length); |
| 257 } | 255 } |
| 258 | 256 |
| 259 | 257 |
| 260 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { | 258 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 | 364 |
| 367 | 365 |
| 368 void V8::ClearWeak(void** obj) { | 366 void V8::ClearWeak(void** obj) { |
| 369 LOG_API("ClearWeak"); | 367 LOG_API("ClearWeak"); |
| 370 i::GlobalHandles::ClearWeakness(reinterpret_cast<i::Object**>(obj)); | 368 i::GlobalHandles::ClearWeakness(reinterpret_cast<i::Object**>(obj)); |
| 371 } | 369 } |
| 372 | 370 |
| 373 | 371 |
| 374 bool V8::IsGlobalNearDeath(void** obj) { | 372 bool V8::IsGlobalNearDeath(void** obj) { |
| 375 LOG_API("IsGlobalNearDeath"); | 373 LOG_API("IsGlobalNearDeath"); |
| 376 if (has_shut_down) return false; | 374 if (!i::V8::IsRunning()) return false; |
| 377 return i::GlobalHandles::IsNearDeath(reinterpret_cast<i::Object**>(obj)); | 375 return i::GlobalHandles::IsNearDeath(reinterpret_cast<i::Object**>(obj)); |
| 378 } | 376 } |
| 379 | 377 |
| 380 | 378 |
| 381 bool V8::IsGlobalWeak(void** obj) { | 379 bool V8::IsGlobalWeak(void** obj) { |
| 382 LOG_API("IsGlobalWeak"); | 380 LOG_API("IsGlobalWeak"); |
| 383 if (has_shut_down) return false; | 381 if (!i::V8::IsRunning()) return false; |
| 384 return i::GlobalHandles::IsWeak(reinterpret_cast<i::Object**>(obj)); | 382 return i::GlobalHandles::IsWeak(reinterpret_cast<i::Object**>(obj)); |
| 385 } | 383 } |
| 386 | 384 |
| 387 | 385 |
| 388 void V8::DisposeGlobal(void** obj) { | 386 void V8::DisposeGlobal(void** obj) { |
| 389 LOG_API("DisposeGlobal"); | 387 LOG_API("DisposeGlobal"); |
| 390 if (has_shut_down) return; | 388 if (!i::V8::IsRunning()) return; |
| 391 i::Object** ptr = reinterpret_cast<i::Object**>(obj); | 389 i::Object** ptr = reinterpret_cast<i::Object**>(obj); |
| 392 if ((*ptr)->IsGlobalContext()) i::Heap::NotifyContextDisposed(); | 390 if ((*ptr)->IsGlobalContext()) i::Heap::NotifyContextDisposed(); |
| 393 i::GlobalHandles::Destroy(ptr); | 391 i::GlobalHandles::Destroy(ptr); |
| 394 } | 392 } |
| 395 | 393 |
| 396 // --- H a n d l e s --- | 394 // --- H a n d l e s --- |
| 397 | 395 |
| 398 | 396 |
| 399 HandleScope::HandleScope() : is_closed_(false) { | 397 HandleScope::HandleScope() : is_closed_(false) { |
| 400 API_ENTRY_CHECK("HandleScope::HandleScope"); | 398 API_ENTRY_CHECK("HandleScope::HandleScope"); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 424 ENTER_V8; | 422 ENTER_V8; |
| 425 i::Handle<i::Context> env = Utils::OpenHandle(this); | 423 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 426 thread_local.EnterContext(env); | 424 thread_local.EnterContext(env); |
| 427 | 425 |
| 428 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); | 426 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); |
| 429 i::Top::set_context(*env); | 427 i::Top::set_context(*env); |
| 430 } | 428 } |
| 431 | 429 |
| 432 | 430 |
| 433 void Context::Exit() { | 431 void Context::Exit() { |
| 434 if (has_shut_down) return; | 432 if (!i::V8::IsRunning()) return; |
| 435 if (!ApiCheck(thread_local.LeaveLastContext(), | 433 if (!ApiCheck(thread_local.LeaveLastContext(), |
| 436 "v8::Context::Exit()", | 434 "v8::Context::Exit()", |
| 437 "Cannot exit non-entered context")) { | 435 "Cannot exit non-entered context")) { |
| 438 return; | 436 return; |
| 439 } | 437 } |
| 440 | 438 |
| 441 // Content of 'last_context' could be NULL. | 439 // Content of 'last_context' could be NULL. |
| 442 i::Handle<i::Object> last_context = thread_local.RestoreContext(); | 440 i::Handle<i::Object> last_context = thread_local.RestoreContext(); |
| 443 i::Top::set_context(static_cast<i::Context*>(*last_context)); | 441 i::Top::set_context(static_cast<i::Context*>(*last_context)); |
| 444 i::GlobalHandles::Destroy(last_context.location()); | 442 i::GlobalHandles::Destroy(last_context.location()); |
| (...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2443 } | 2441 } |
| 2444 ENTER_V8; | 2442 ENTER_V8; |
| 2445 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 2443 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
| 2446 obj->SetInternalField(index, *val); | 2444 obj->SetInternalField(index, *val); |
| 2447 } | 2445 } |
| 2448 | 2446 |
| 2449 | 2447 |
| 2450 // --- E n v i r o n m e n t --- | 2448 // --- E n v i r o n m e n t --- |
| 2451 | 2449 |
| 2452 bool v8::V8::Initialize() { | 2450 bool v8::V8::Initialize() { |
| 2453 if (i::V8::HasBeenSetup()) return true; | 2451 if (i::V8::IsRunning()) return true; |
| 2454 ENTER_V8; | 2452 ENTER_V8; |
| 2455 HandleScope scope; | 2453 HandleScope scope; |
| 2456 if (i::Snapshot::Initialize()) { | 2454 if (i::Snapshot::Initialize()) { |
| 2457 return true; | 2455 return true; |
| 2458 } else { | 2456 } else { |
| 2459 return i::V8::Initialize(NULL); | 2457 return i::V8::Initialize(NULL); |
| 2460 } | 2458 } |
| 2461 } | 2459 } |
| 2462 | 2460 |
| 2463 | 2461 |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3051 NeanderObject listener(i::JSObject::cast(listeners.get(i))); | 3049 NeanderObject listener(i::JSObject::cast(listeners.get(i))); |
| 3052 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); | 3050 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); |
| 3053 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { | 3051 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { |
| 3054 listeners.set(i, i::Heap::undefined_value()); | 3052 listeners.set(i, i::Heap::undefined_value()); |
| 3055 } | 3053 } |
| 3056 } | 3054 } |
| 3057 } | 3055 } |
| 3058 | 3056 |
| 3059 | 3057 |
| 3060 void V8::SetCounterFunction(CounterLookupCallback callback) { | 3058 void V8::SetCounterFunction(CounterLookupCallback callback) { |
| 3061 if (IsDeadCheck("v8::V8::SetCounterFunction()")) return; | |
| 3062 i::StatsTable::SetCounterFunction(callback); | 3059 i::StatsTable::SetCounterFunction(callback); |
|
iposva
2009/05/07 23:04:06
Should we reintroduce the IsDeadCheck here?
| |
| 3063 } | 3060 } |
| 3064 | 3061 |
| 3065 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { | 3062 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { |
| 3066 if (IsDeadCheck("v8::V8::SetCreateHistogramFunction()")) return; | |
| 3067 i::StatsTable::SetCreateHistogramFunction(callback); | 3063 i::StatsTable::SetCreateHistogramFunction(callback); |
|
iposva
2009/05/07 23:04:06
ditto
| |
| 3068 } | 3064 } |
| 3069 | 3065 |
| 3070 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { | 3066 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { |
| 3071 if (IsDeadCheck("v8::V8::SetAddHistogramSampleFunction()")) return; | |
| 3072 i::StatsTable::SetAddHistogramSampleFunction(callback); | 3067 i::StatsTable::SetAddHistogramSampleFunction(callback); |
|
iposva
2009/05/07 23:04:06
ditto
| |
| 3073 } | 3068 } |
| 3074 | 3069 |
| 3075 void V8::EnableSlidingStateWindow() { | 3070 void V8::EnableSlidingStateWindow() { |
| 3076 if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return; | 3071 if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return; |
| 3077 i::Logger::EnableSlidingStateWindow(); | 3072 i::Logger::EnableSlidingStateWindow(); |
| 3078 } | 3073 } |
| 3079 | 3074 |
| 3080 | 3075 |
| 3081 void V8::SetFailedAccessCheckCallbackFunction( | 3076 void V8::SetFailedAccessCheckCallbackFunction( |
| 3082 FailedAccessCheckCallback callback) { | 3077 FailedAccessCheckCallback callback) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3305 Handle<Value> data) { | 3300 Handle<Value> data) { |
| 3306 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); | 3301 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); |
| 3307 ENTER_V8; | 3302 ENTER_V8; |
| 3308 i::Debugger::SetEventListener(Utils::OpenHandle(*that), | 3303 i::Debugger::SetEventListener(Utils::OpenHandle(*that), |
| 3309 Utils::OpenHandle(*data)); | 3304 Utils::OpenHandle(*data)); |
| 3310 return true; | 3305 return true; |
| 3311 } | 3306 } |
| 3312 | 3307 |
| 3313 | 3308 |
| 3314 void Debug::DebugBreak() { | 3309 void Debug::DebugBreak() { |
| 3315 if (!i::V8::HasBeenSetup()) return; | 3310 if (!i::V8::IsRunning()) return; |
| 3316 i::StackGuard::DebugBreak(); | 3311 i::StackGuard::DebugBreak(); |
| 3317 } | 3312 } |
| 3318 | 3313 |
| 3319 | 3314 |
| 3320 static v8::Debug::MessageHandler message_handler = NULL; | 3315 static v8::Debug::MessageHandler message_handler = NULL; |
| 3321 | 3316 |
| 3322 static void MessageHandlerWrapper(const v8::Debug::Message& message) { | 3317 static void MessageHandlerWrapper(const v8::Debug::Message& message) { |
| 3323 if (message_handler) { | 3318 if (message_handler) { |
| 3324 v8::String::Value json(message.GetJSON()); | 3319 v8::String::Value json(message.GetJSON()); |
| 3325 message_handler(*json, json.length(), message.GetClientData()); | 3320 message_handler(*json, json.length(), message.GetClientData()); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 3347 | 3342 |
| 3348 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { | 3343 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { |
| 3349 EnsureInitialized("v8::Debug::SetMessageHandler"); | 3344 EnsureInitialized("v8::Debug::SetMessageHandler"); |
| 3350 ENTER_V8; | 3345 ENTER_V8; |
| 3351 i::Debugger::SetMessageHandler(handler); | 3346 i::Debugger::SetMessageHandler(handler); |
| 3352 } | 3347 } |
| 3353 | 3348 |
| 3354 | 3349 |
| 3355 void Debug::SendCommand(const uint16_t* command, int length, | 3350 void Debug::SendCommand(const uint16_t* command, int length, |
| 3356 ClientData* client_data) { | 3351 ClientData* client_data) { |
| 3357 if (!i::V8::HasBeenSetup()) return; | 3352 if (!i::V8::IsRunning()) return; |
| 3358 i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length), | 3353 i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length), |
| 3359 client_data); | 3354 client_data); |
| 3360 } | 3355 } |
| 3361 | 3356 |
| 3362 | 3357 |
| 3363 void Debug::SetHostDispatchHandler(HostDispatchHandler handler, | 3358 void Debug::SetHostDispatchHandler(HostDispatchHandler handler, |
| 3364 int period) { | 3359 int period) { |
| 3365 EnsureInitialized("v8::Debug::SetHostDispatchHandler"); | 3360 EnsureInitialized("v8::Debug::SetHostDispatchHandler"); |
| 3366 ENTER_V8; | 3361 ENTER_V8; |
| 3367 i::Debugger::SetHostDispatchHandler(handler, period); | 3362 i::Debugger::SetHostDispatchHandler(handler, period); |
| 3368 } | 3363 } |
| 3369 | 3364 |
| 3370 | 3365 |
| 3371 Handle<Value> Debug::Call(v8::Handle<v8::Function> fun, | 3366 Handle<Value> Debug::Call(v8::Handle<v8::Function> fun, |
| 3372 v8::Handle<v8::Value> data) { | 3367 v8::Handle<v8::Value> data) { |
| 3373 if (!i::V8::HasBeenSetup()) return Handle<Value>(); | 3368 if (!i::V8::IsRunning()) return Handle<Value>(); |
| 3374 ON_BAILOUT("v8::Debug::Call()", return Handle<Value>()); | 3369 ON_BAILOUT("v8::Debug::Call()", return Handle<Value>()); |
| 3375 ENTER_V8; | 3370 ENTER_V8; |
| 3376 i::Handle<i::Object> result; | 3371 i::Handle<i::Object> result; |
| 3377 EXCEPTION_PREAMBLE(); | 3372 EXCEPTION_PREAMBLE(); |
| 3378 if (data.IsEmpty()) { | 3373 if (data.IsEmpty()) { |
| 3379 result = i::Debugger::Call(Utils::OpenHandle(*fun), | 3374 result = i::Debugger::Call(Utils::OpenHandle(*fun), |
| 3380 i::Factory::undefined_value(), | 3375 i::Factory::undefined_value(), |
| 3381 &has_pending_exception); | 3376 &has_pending_exception); |
| 3382 } else { | 3377 } else { |
| 3383 result = i::Debugger::Call(Utils::OpenHandle(*fun), | 3378 result = i::Debugger::Call(Utils::OpenHandle(*fun), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3468 reinterpret_cast<HandleScopeImplementer*>(storage); | 3463 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3469 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3464 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 3470 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3465 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 3471 &thread_local->handle_scope_data_; | 3466 &thread_local->handle_scope_data_; |
| 3472 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3467 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 3473 | 3468 |
| 3474 return storage + ArchiveSpacePerThread(); | 3469 return storage + ArchiveSpacePerThread(); |
| 3475 } | 3470 } |
| 3476 | 3471 |
| 3477 } } // namespace v8::internal | 3472 } } // namespace v8::internal |
| OLD | NEW |