OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 ASSERT(script.IsEmpty()); | 371 ASSERT(script.IsEmpty()); |
372 | 372 |
373 // Keep Frame (and therefore ScriptController and V8Proxy) alive. | 373 // Keep Frame (and therefore ScriptController and V8Proxy) alive. |
374 RefPtr<Frame> protect(frame()); | 374 RefPtr<Frame> protect(frame()); |
375 | 375 |
376 // Run the script and keep track of the current recursion depth. | 376 // Run the script and keep track of the current recursion depth. |
377 v8::Local<v8::Value> result; | 377 v8::Local<v8::Value> result; |
378 v8::TryCatch tryCatch; | 378 v8::TryCatch tryCatch; |
379 tryCatch.SetVerbose(true); | 379 tryCatch.SetVerbose(true); |
380 { | 380 { |
381 V8RecursionScope recursionScope; | 381 V8RecursionScope recursionScope(frame()->document()); |
382 result = script->Run(); | 382 result = script->Run(); |
383 } | 383 } |
384 | 384 |
385 if (handleOutOfMemory()) | 385 if (handleOutOfMemory()) |
386 ASSERT(result.IsEmpty()); | 386 ASSERT(result.IsEmpty()); |
387 | 387 |
388 // Handle V8 internal error situation (Out-of-memory). | 388 // Handle V8 internal error situation (Out-of-memory). |
389 if (tryCatch.HasCaught()) { | 389 if (tryCatch.HasCaught()) { |
390 ASSERT(result.IsEmpty()); | 390 ASSERT(result.IsEmpty()); |
391 return notHandledByInterceptor(); | 391 return notHandledByInterceptor(); |
392 } | 392 } |
393 | 393 |
394 if (result.IsEmpty()) | 394 if (result.IsEmpty()) |
395 return notHandledByInterceptor(); | 395 return notHandledByInterceptor(); |
396 | 396 |
397 if (v8::V8::IsDead()) | 397 if (v8::V8::IsDead()) |
398 handleFatalErrorInV8(); | 398 handleFatalErrorInV8(); |
399 | 399 |
400 return result; | 400 return result; |
401 } | 401 } |
402 | 402 |
403 v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8
::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]) | 403 v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8
::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]) |
404 { | 404 { |
405 // Keep Frame (and therefore ScriptController and V8Proxy) alive. | 405 // Keep Frame (and therefore ScriptController and V8Proxy) alive. |
406 RefPtr<Frame> protect(frame()); | 406 RefPtr<Frame> protect(frame()); |
407 return V8Proxy::instrumentedCallFunction(m_frame->page(), function, receiver
, argc, args); | 407 return V8Proxy::instrumentedCallFunction(frame(), function, receiver, argc,
args); |
408 } | 408 } |
409 | 409 |
410 v8::Local<v8::Value> V8Proxy::instrumentedCallFunction(Page* page, v8::Handle<v8
::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::
Value> args[]) | 410 v8::Local<v8::Value> V8Proxy::instrumentedCallFunction(Frame* frame, v8::Handle<
v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8
::Value> args[]) |
411 { | 411 { |
412 V8GCController::checkMemoryUsage(); | 412 V8GCController::checkMemoryUsage(); |
413 | 413 |
414 if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth) | 414 if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth) |
415 return handleMaxRecursionDepthExceeded(); | 415 return handleMaxRecursionDepthExceeded(); |
416 | 416 |
417 InspectorInstrumentationCookie cookie; | 417 InspectorInstrumentationCookie cookie; |
418 if (InspectorInstrumentation::hasFrontends()) { | 418 if (InspectorInstrumentation::hasFrontends() && frame) { |
419 String resourceName("undefined"); | 419 String resourceName("undefined"); |
420 int lineNumber = 1; | 420 int lineNumber = 1; |
421 v8::ScriptOrigin origin = function->GetScriptOrigin(); | 421 v8::ScriptOrigin origin = function->GetScriptOrigin(); |
422 if (!origin.ResourceName().IsEmpty()) { | 422 if (!origin.ResourceName().IsEmpty()) { |
423 resourceName = toWebCoreString(origin.ResourceName()); | 423 resourceName = toWebCoreString(origin.ResourceName()); |
424 lineNumber = function->GetScriptLineNumber() + 1; | 424 lineNumber = function->GetScriptLineNumber() + 1; |
425 } | 425 } |
426 cookie = InspectorInstrumentation::willCallFunction(page, resourceName,
lineNumber); | 426 cookie = InspectorInstrumentation::willCallFunction(frame->page(), resou
rceName, lineNumber); |
427 } | 427 } |
428 | 428 |
429 v8::Local<v8::Value> result; | 429 v8::Local<v8::Value> result; |
430 { | 430 { |
431 V8RecursionScope recursionScope; | 431 V8RecursionScope recursionScope(frame ? frame->document() : 0); |
432 result = function->Call(receiver, argc, args); | 432 result = function->Call(receiver, argc, args); |
433 } | 433 } |
434 | 434 |
435 InspectorInstrumentation::didCallFunction(cookie); | 435 InspectorInstrumentation::didCallFunction(cookie); |
436 | 436 |
437 if (v8::V8::IsDead()) | 437 if (v8::V8::IsDead()) |
438 handleFatalErrorInV8(); | 438 handleFatalErrorInV8(); |
439 | 439 |
440 return result; | 440 return result; |
441 } | 441 } |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 #if ENABLE(WORKERS) | 726 #if ENABLE(WORKERS) |
727 } else if (context->isWorkerContext()) { | 727 } else if (context->isWorkerContext()) { |
728 if (WorkerContextExecutionProxy* proxy = static_cast<WorkerContext*>(con
text)->script()->proxy()) | 728 if (WorkerContextExecutionProxy* proxy = static_cast<WorkerContext*>(con
text)->script()->proxy()) |
729 return proxy->context(); | 729 return proxy->context(); |
730 #endif | 730 #endif |
731 } | 731 } |
732 return v8::Local<v8::Context>(); | 732 return v8::Local<v8::Context>(); |
733 } | 733 } |
734 | 734 |
735 } // namespace WebCore | 735 } // namespace WebCore |
OLD | NEW |