| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 { | 53 { |
| 54 return value ? v8::True(isolate) : v8::False(isolate); | 54 return value ? v8::True(isolate) : v8::False(isolate); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } | 57 } |
| 58 | 58 |
| 59 static bool inLiveEditScope = false; | 59 static bool inLiveEditScope = false; |
| 60 | 60 |
| 61 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functio
nName, int argc, v8::Local<v8::Value> argv[]) | 61 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functio
nName, int argc, v8::Local<v8::Value> argv[]) |
| 62 { | 62 { |
| 63 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | |
| 64 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); | 63 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); |
| 65 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr
ipt->Get(v8InternalizedString(functionName))); | 64 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr
ipt->Get(v8InternalizedString(functionName))); |
| 66 ASSERT(m_isolate->InContext()); | 65 ASSERT(m_isolate->InContext()); |
| 67 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc,
argv); | 66 return m_client->callInternalFunction(function, debuggerScript, argc, argv); |
| 68 } | 67 } |
| 69 | 68 |
| 70 PassOwnPtr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient
* client) | 69 PassOwnPtr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient
* client) |
| 71 { | 70 { |
| 72 return adoptPtr(new V8DebuggerImpl(isolate, client)); | 71 return adoptPtr(new V8DebuggerImpl(isolate, client)); |
| 73 } | 72 } |
| 74 | 73 |
| 75 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) | 74 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) |
| 76 : m_isolate(isolate) | 75 : m_isolate(isolate) |
| 77 , m_client(client) | 76 , m_client(client) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 { | 203 { |
| 205 int groupId = getGroupId(context); | 204 int groupId = getGroupId(context); |
| 206 if (!groupId) | 205 if (!groupId) |
| 207 return nullptr; | 206 return nullptr; |
| 208 return m_runtimeAgentsMap.get(groupId); | 207 return m_runtimeAgentsMap.get(groupId); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D
ebuggerParsedScript>& result) | 210 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D
ebuggerParsedScript>& result) |
| 212 { | 211 { |
| 213 v8::HandleScope scope(m_isolate); | 212 v8::HandleScope scope(m_isolate); |
| 213 v8::Context::Scope contextScope(debuggerContext()); |
| 214 |
| 214 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); | 215 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); |
| 215 ASSERT(!debuggerScript->IsUndefined()); | 216 ASSERT(!debuggerScript->IsUndefined()); |
| 216 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(v8InternalizedString("getScripts"))); | 217 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(v8InternalizedString("getScripts"))); |
| 217 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId)
}; | 218 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId)
}; |
| 218 v8::Local<v8::Value> value; | 219 v8::Local<v8::Value> value; |
| 219 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | 220 if (!m_client->callInternalFunction(getScriptsFunction, debuggerScript, WTF_
ARRAY_LENGTH(argv), argv).ToLocal(&value)) |
| 220 if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, WTF_ARRAY_L
ENGTH(argv), argv).ToLocal(&value)) | |
| 221 return; | 221 return; |
| 222 ASSERT(value->IsArray()); | 222 ASSERT(value->IsArray()); |
| 223 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); | 223 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); |
| 224 result.resize(scriptsArray->Length()); | 224 result.resize(scriptsArray->Length()); |
| 225 for (unsigned i = 0; i < scriptsArray->Length(); ++i) | 225 for (unsigned i = 0; i < scriptsArray->Length(); ++i) |
| 226 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray-
>Get(v8::Integer::New(m_isolate, i))), true); | 226 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray-
>Get(v8::Integer::New(m_isolate, i))), true); |
| 227 } | 227 } |
| 228 | 228 |
| 229 String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBre
akpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool
interstatementLocation) | 229 String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBre
akpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool
interstatementLocation) |
| 230 { | 230 { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 if (m_executionState.IsEmpty()) { | 485 if (m_executionState.IsEmpty()) { |
| 486 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallF
rame"))); | 486 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallF
rame"))); |
| 487 currentCallFrameV8 = v8::Debug::Call(debuggerContext(), currentCallFrame
Function).ToLocalChecked(); | 487 currentCallFrameV8 = v8::Debug::Call(debuggerContext(), currentCallFrame
Function).ToLocalChecked(); |
| 488 } else { | 488 } else { |
| 489 v8::Local<v8::Value> argv[] = { m_executionState }; | 489 v8::Local<v8::Value> argv[] = { m_executionState }; |
| 490 currentCallFrameV8 = callDebuggerMethod("currentCallFrame", WTF_ARRAY_LE
NGTH(argv), argv).ToLocalChecked(); | 490 currentCallFrameV8 = callDebuggerMethod("currentCallFrame", WTF_ARRAY_LE
NGTH(argv), argv).ToLocalChecked(); |
| 491 } | 491 } |
| 492 ASSERT(!currentCallFrameV8.IsEmpty()); | 492 ASSERT(!currentCallFrameV8.IsEmpty()); |
| 493 if (!currentCallFrameV8->IsObject()) | 493 if (!currentCallFrameV8->IsObject()) |
| 494 return nullptr; | 494 return nullptr; |
| 495 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>:
:Cast(currentCallFrameV8)); | 495 return JavaScriptCallFrame::create(m_client, debuggerContext(), v8::Local<v8
::Object>::Cast(currentCallFrameV8)); |
| 496 } | 496 } |
| 497 | 497 |
| 498 v8::Local<v8::Object> V8DebuggerImpl::currentCallFrames() | 498 v8::Local<v8::Object> V8DebuggerImpl::currentCallFrames() |
| 499 { | 499 { |
| 500 if (!m_isolate->InContext()) | 500 if (!m_isolate->InContext()) |
| 501 return v8::Local<v8::Object>(); | 501 return v8::Local<v8::Object>(); |
| 502 | 502 |
| 503 // Filter out stack traces entirely consisting of V8's internal scripts. | 503 // Filter out stack traces entirely consisting of V8's internal scripts. |
| 504 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_i
solate, 1); | 504 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_i
solate, 1); |
| 505 if (!stackTrace->GetFrameCount()) | 505 if (!stackTrace->GetFrameCount()) |
| 506 return v8::Local<v8::Object>(); | 506 return v8::Local<v8::Object>(); |
| 507 | 507 |
| 508 OwnPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(); | 508 OwnPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(); |
| 509 if (!currentCallFrame) | 509 if (!currentCallFrame) |
| 510 return v8::Local<v8::Object>(); | 510 return v8::Local<v8::Object>(); |
| 511 | 511 |
| 512 v8::Local<v8::FunctionTemplate> wrapperTemplate = v8::Local<v8::FunctionTemp
late>::New(m_isolate, m_callFrameWrapperTemplate); | 512 v8::Local<v8::FunctionTemplate> wrapperTemplate = v8::Local<v8::FunctionTemp
late>::New(m_isolate, m_callFrameWrapperTemplate); |
| 513 v8::Local<v8::Context> context = m_pausedContext.IsEmpty() ? m_isolate->GetC
urrentContext() : m_pausedContext; | 513 v8::Local<v8::Context> context = m_pausedContext.IsEmpty() ? m_isolate->GetC
urrentContext() : m_pausedContext; |
| 514 v8::Context::Scope scope(context); | 514 v8::Context::Scope scope(context); |
| 515 v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(wrapperTemplate,
context, currentCallFrame.release()); | 515 v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(m_client, wrappe
rTemplate, context, currentCallFrame.release()); |
| 516 return wrapper; | 516 return wrapper; |
| 517 } | 517 } |
| 518 | 518 |
| 519 PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::callFrameNoScopes(int index) | 519 PassOwnPtr<JavaScriptCallFrame> V8DebuggerImpl::callFrameNoScopes(int index) |
| 520 { | 520 { |
| 521 if (!m_isolate->InContext()) | 521 if (!m_isolate->InContext()) |
| 522 return nullptr; | 522 return nullptr; |
| 523 v8::HandleScope handleScope(m_isolate); | 523 v8::HandleScope handleScope(m_isolate); |
| 524 | 524 |
| 525 v8::Local<v8::Value> currentCallFrameV8; | 525 v8::Local<v8::Value> currentCallFrameV8; |
| 526 if (m_executionState.IsEmpty()) { | 526 if (m_executionState.IsEmpty()) { |
| 527 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallF
rameByIndex"))); | 527 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallF
rameByIndex"))); |
| 528 currentCallFrameV8 = v8::Debug::Call(debuggerContext(), currentCallFrame
Function, v8::Integer::New(m_isolate, index)).ToLocalChecked(); | 528 currentCallFrameV8 = v8::Debug::Call(debuggerContext(), currentCallFrame
Function, v8::Integer::New(m_isolate, index)).ToLocalChecked(); |
| 529 } else { | 529 } else { |
| 530 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso
late, index) }; | 530 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso
late, index) }; |
| 531 currentCallFrameV8 = callDebuggerMethod("currentCallFrameByIndex", WTF_A
RRAY_LENGTH(argv), argv).ToLocalChecked(); | 531 currentCallFrameV8 = callDebuggerMethod("currentCallFrameByIndex", WTF_A
RRAY_LENGTH(argv), argv).ToLocalChecked(); |
| 532 } | 532 } |
| 533 ASSERT(!currentCallFrameV8.IsEmpty()); | 533 ASSERT(!currentCallFrameV8.IsEmpty()); |
| 534 if (!currentCallFrameV8->IsObject()) | 534 if (!currentCallFrameV8->IsObject()) |
| 535 return nullptr; | 535 return nullptr; |
| 536 return JavaScriptCallFrame::create(debuggerContext(), v8::Local<v8::Object>:
:Cast(currentCallFrameV8)); | 536 return JavaScriptCallFrame::create(m_client, debuggerContext(), v8::Local<v8
::Object>::Cast(currentCallFrameV8)); |
| 537 } | 537 } |
| 538 | 538 |
| 539 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data) | 539 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data) |
| 540 { | 540 { |
| 541 void* p = v8::Local<v8::External>::Cast(data)->Value(); | 541 void* p = v8::Local<v8::External>::Cast(data)->Value(); |
| 542 return static_cast<V8DebuggerImpl*>(p); | 542 return static_cast<V8DebuggerImpl*>(p); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val
ue>& info) | 545 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val
ue>& info) |
| 546 { | 546 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 void V8DebuggerImpl::v8DebugEventCallback(const v8::Debug::EventDetails& eventDe
tails) | 604 void V8DebuggerImpl::v8DebugEventCallback(const v8::Debug::EventDetails& eventDe
tails) |
| 605 { | 605 { |
| 606 V8DebuggerImpl* thisPtr = toV8DebuggerImpl(eventDetails.GetCallbackData()); | 606 V8DebuggerImpl* thisPtr = toV8DebuggerImpl(eventDetails.GetCallbackData()); |
| 607 thisPtr->handleV8DebugEvent(eventDetails); | 607 thisPtr->handleV8DebugEvent(eventDetails); |
| 608 } | 608 } |
| 609 | 609 |
| 610 v8::Local<v8::Value> V8DebuggerImpl::callInternalGetterFunction(v8::Local<v8::Ob
ject> object, const char* functionName) | 610 v8::Local<v8::Value> V8DebuggerImpl::callInternalGetterFunction(v8::Local<v8::Ob
ject> object, const char* functionName) |
| 611 { | 611 { |
| 612 v8::Local<v8::Value> getterValue = object->Get(v8InternalizedString(function
Name)); | 612 v8::Local<v8::Value> getterValue = object->Get(v8InternalizedString(function
Name)); |
| 613 ASSERT(!getterValue.IsEmpty() && getterValue->IsFunction()); | 613 ASSERT(!getterValue.IsEmpty() && getterValue->IsFunction()); |
| 614 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | 614 return m_client->callInternalFunction(v8::Local<v8::Function>::Cast(getterVa
lue), object, 0, 0).ToLocalChecked(); |
| 615 return v8::Local<v8::Function>::Cast(getterValue)->Call(m_isolate->GetCurren
tContext(), object, 0, 0).ToLocalChecked(); | |
| 616 } | 615 } |
| 617 | 616 |
| 618 void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta
ils) | 617 void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta
ils) |
| 619 { | 618 { |
| 620 if (!enabled()) | 619 if (!enabled()) |
| 621 return; | 620 return; |
| 622 v8::DebugEvent event = eventDetails.GetEvent(); | 621 v8::DebugEvent event = eventDetails.GetEvent(); |
| 623 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError && event != v8::PromiseEvent) | 622 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError && event != v8::PromiseEvent) |
| 624 return; | 623 return; |
| 625 | 624 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 if (!m_debuggerScript.IsEmpty()) { | 714 if (!m_debuggerScript.IsEmpty()) { |
| 716 ASSERT_NOT_REACHED(); | 715 ASSERT_NOT_REACHED(); |
| 717 return; | 716 return; |
| 718 } | 717 } |
| 719 | 718 |
| 720 v8::HandleScope scope(m_isolate); | 719 v8::HandleScope scope(m_isolate); |
| 721 v8::Context::Scope contextScope(debuggerContext()); | 720 v8::Context::Scope contextScope(debuggerContext()); |
| 722 | 721 |
| 723 v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, Debug
gerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLoc
alChecked(); | 722 v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, Debug
gerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLoc
alChecked(); |
| 724 v8::Local<v8::Value> value; | 723 v8::Local<v8::Value> value; |
| 725 if (!compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&va
lue)) | 724 if (!m_client->compileAndRunInternalScript(scriptValue).ToLocal(&value)) |
| 726 return; | 725 return; |
| 727 ASSERT(value->IsObject()); | 726 ASSERT(value->IsObject()); |
| 728 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); | 727 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); |
| 729 } | 728 } |
| 730 | 729 |
| 731 v8::Local<v8::Context> V8DebuggerImpl::debuggerContext() const | 730 v8::Local<v8::Context> V8DebuggerImpl::debuggerContext() const |
| 732 { | 731 { |
| 733 ASSERT(!m_debuggerContext.IsEmpty()); | 732 ASSERT(!m_debuggerContext.IsEmpty()); |
| 734 return m_debuggerContext.Get(m_isolate); | 733 return m_debuggerContext.Get(m_isolate); |
| 735 } | 734 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 }; | 783 }; |
| 785 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 784 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
| 786 } | 785 } |
| 787 | 786 |
| 788 | 787 |
| 789 bool V8DebuggerImpl::isPaused() | 788 bool V8DebuggerImpl::isPaused() |
| 790 { | 789 { |
| 791 return !m_pausedContext.IsEmpty(); | 790 return !m_pausedContext.IsEmpty(); |
| 792 } | 791 } |
| 793 | 792 |
| 794 v8::MaybeLocal<v8::Value> V8DebuggerImpl::runCompiledScript(v8::Local<v8::Contex
t> context, v8::Local<v8::Script> script) | 793 v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Contex
t>, v8::Local<v8::String> code, const String16& fileName) |
| 795 { | |
| 796 // TODO(dgozman): get rid of this check. | |
| 797 if (!m_client->isExecutionAllowed()) | |
| 798 return v8::MaybeLocal<v8::Value>(); | |
| 799 | |
| 800 v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicr
otasks); | |
| 801 int groupId = getGroupId(context); | |
| 802 V8DebuggerAgentImpl* agent = groupId ? m_debuggerAgentsMap.get(groupId) : nu
llptr; | |
| 803 if (agent) | |
| 804 agent->willExecuteScript(script->GetUnboundScript()->GetId()); | |
| 805 v8::MaybeLocal<v8::Value> result = script->Run(context); | |
| 806 // Get agent from the map again, since it could have detached during script
execution. | |
| 807 agent = groupId ? m_debuggerAgentsMap.get(groupId) : nullptr; | |
| 808 if (agent) | |
| 809 agent->didExecuteScript(); | |
| 810 return result; | |
| 811 } | |
| 812 | |
| 813 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callFunction(v8::Local<v8::Function> f
unction, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc
, v8::Local<v8::Value> info[]) | |
| 814 { | |
| 815 // TODO(dgozman): get rid of this check. | |
| 816 if (!m_client->isExecutionAllowed()) | |
| 817 return v8::MaybeLocal<v8::Value>(); | |
| 818 | |
| 819 v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicr
otasks); | |
| 820 int groupId = getGroupId(context); | |
| 821 V8DebuggerAgentImpl* agent = groupId ? m_debuggerAgentsMap.get(groupId) : nu
llptr; | |
| 822 if (agent) | |
| 823 agent->willExecuteScript(function->ScriptId()); | |
| 824 v8::MaybeLocal<v8::Value> result = function->Call(context, receiver, argc, i
nfo); | |
| 825 // Get agent from the map again, since it could have detached during script
execution. | |
| 826 agent = groupId ? m_debuggerAgentsMap.get(groupId) : nullptr; | |
| 827 if (agent) | |
| 828 agent->didExecuteScript(); | |
| 829 return result; | |
| 830 } | |
| 831 | |
| 832 v8::MaybeLocal<v8::Value> V8DebuggerImpl::compileAndRunInternalScript(v8::Local<
v8::Context> context, v8::Local<v8::String> source) | |
| 833 { | |
| 834 v8::Local<v8::Script> script = compileInternalScript(context, source, String
()); | |
| 835 if (script.IsEmpty()) | |
| 836 return v8::MaybeLocal<v8::Value>(); | |
| 837 v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kDoNotRu
nMicrotasks); | |
| 838 return script->Run(context); | |
| 839 } | |
| 840 | |
| 841 v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Contex
t> context, v8::Local<v8::String> code, const String16& fileName) | |
| 842 { | 794 { |
| 843 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at | 795 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at |
| 844 // 1, whereas v8 starts at 0. | 796 // 1, whereas v8 starts at 0. |
| 845 v8::ScriptOrigin origin( | 797 v8::ScriptOrigin origin( |
| 846 toV8String(m_isolate, fileName), | 798 toV8String(m_isolate, fileName), |
| 847 v8::Integer::New(m_isolate, 0), | 799 v8::Integer::New(m_isolate, 0), |
| 848 v8::Integer::New(m_isolate, 0), | 800 v8::Integer::New(m_isolate, 0), |
| 849 v8::False(m_isolate), // sharable | 801 v8::False(m_isolate), // sharable |
| 850 v8::Local<v8::Integer>(), | 802 v8::Local<v8::Integer>(), |
| 851 v8::True(m_isolate), // internal | 803 v8::True(m_isolate), // internal |
| 852 toV8String(m_isolate, String16()), // sourceMap | 804 toV8String(m_isolate, String16()), // sourceMap |
| 853 v8::True(m_isolate)); // opaqueresource | 805 v8::True(m_isolate)); // opaqueresource |
| 854 v8::ScriptCompiler::Source source(code, origin); | 806 v8::ScriptCompiler::Source source(code, origin); |
| 855 v8::Local<v8::Script> script; | 807 v8::Local<v8::Script> script; |
| 856 if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCo
mpileOptions).ToLocal(&script)) | 808 if (!v8::ScriptCompiler::Compile(m_isolate->GetCurrentContext(), &source, v8
::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) |
| 857 return v8::Local<v8::Script>(); | 809 return v8::Local<v8::Script>(); |
| 858 return script; | 810 return script; |
| 859 } | 811 } |
| 860 | 812 |
| 861 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra
ce> stackTrace, size_t maxStackSize) | 813 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra
ce> stackTrace, size_t maxStackSize) |
| 862 { | 814 { |
| 863 V8DebuggerAgentImpl* agent = getDebuggerAgentForContext(m_isolate->GetCurren
tContext()); | 815 V8DebuggerAgentImpl* agent = getDebuggerAgentForContext(m_isolate->GetCurren
tContext()); |
| 864 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); | 816 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); |
| 865 } | 817 } |
| 866 | 818 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 885 } | 837 } |
| 886 | 838 |
| 887 v8::Local<v8::Context> V8DebuggerImpl::regexContext() | 839 v8::Local<v8::Context> V8DebuggerImpl::regexContext() |
| 888 { | 840 { |
| 889 if (m_regexContext.IsEmpty()) | 841 if (m_regexContext.IsEmpty()) |
| 890 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); | 842 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); |
| 891 return m_regexContext.Get(m_isolate); | 843 return m_regexContext.Get(m_isolate); |
| 892 } | 844 } |
| 893 | 845 |
| 894 } // namespace blink | 846 } // namespace blink |
| OLD | NEW |