OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 Google Inc. All rights reserved. | 2 * Copyright (c) 2010 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 scriptCallFrames.append(toScriptCallFrame(stackFrame)); | 75 scriptCallFrames.append(toScriptCallFrame(stackFrame)); |
76 } | 76 } |
77 if (!frameCount && !emptyStackIsAllowed) { | 77 if (!frameCount && !emptyStackIsAllowed) { |
78 // Successfully grabbed stack trace, but there are no frames. It may hap
pen in case | 78 // Successfully grabbed stack trace, but there are no frames. It may hap
pen in case |
79 // when a bound function is called from native code for example. | 79 // when a bound function is called from native code for example. |
80 // Fallback to setting lineNumber to 0, and source and function name to
"undefined". | 80 // Fallback to setting lineNumber to 0, and source and function name to
"undefined". |
81 scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0)); | 81 scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0)); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 static PassRefPtr<ScriptCallStack> createScriptCallStack(v8::Handle<v8::StackTra
ce> stackTrace, size_t maxStackSize, bool emptyStackIsAllowed) | 85 static PassRefPtr<ScriptCallStack> createScriptCallStack(v8::Handle<v8::StackTra
ce> stackTrace, size_t maxStackSize, bool emptyStackIsAllowed, v8::Isolate* isol
ate) |
86 { | 86 { |
87 ASSERT(v8::Context::InContext()); | 87 ASSERT(v8::Context::InContext()); |
88 v8::HandleScope scope; | 88 v8::HandleScope scope(isolate); |
89 Vector<ScriptCallFrame> scriptCallFrames; | 89 Vector<ScriptCallFrame> scriptCallFrames; |
90 toScriptCallFramesVector(stackTrace, scriptCallFrames, maxStackSize, emptySt
ackIsAllowed); | 90 toScriptCallFramesVector(stackTrace, scriptCallFrames, maxStackSize, emptySt
ackIsAllowed); |
91 return ScriptCallStack::create(scriptCallFrames); | 91 return ScriptCallStack::create(scriptCallFrames); |
92 } | 92 } |
93 | 93 |
94 PassRefPtr<ScriptCallStack> createScriptCallStack(v8::Handle<v8::StackTrace> sta
ckTrace, size_t maxStackSize) | 94 PassRefPtr<ScriptCallStack> createScriptCallStack(v8::Handle<v8::StackTrace> sta
ckTrace, size_t maxStackSize, v8::Isolate* isolate) |
95 { | 95 { |
96 return createScriptCallStack(stackTrace, maxStackSize, true); | 96 return createScriptCallStack(stackTrace, maxStackSize, true, isolate); |
97 } | 97 } |
98 | 98 |
99 PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool empt
yStackIsAllowed) | 99 PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool empt
yStackIsAllowed) |
100 { | 100 { |
101 if (!v8::Context::InContext()) | 101 if (!v8::Context::InContext()) |
102 return 0; | 102 return 0; |
103 v8::HandleScope handleScope; | 103 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 104 v8::HandleScope handleScope(isolate); |
104 v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxS
tackSize, stackTraceOptions)); | 105 v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxS
tackSize, stackTraceOptions)); |
105 return createScriptCallStack(stackTrace, maxStackSize, emptyStackIsAllowed); | 106 return createScriptCallStack(stackTrace, maxStackSize, emptyStackIsAllowed,
isolate); |
106 } | 107 } |
107 | 108 |
108 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(size_t maxStackSize) | 109 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(size_t maxStackSize) |
109 { | 110 { |
110 size_t stackSize = 1; | 111 size_t stackSize = 1; |
111 if (InspectorInstrumentation::hasFrontends()) { | 112 if (InspectorInstrumentation::hasFrontends()) { |
112 ScriptExecutionContext* scriptExecutionContext = getScriptExecutionConte
xt(); | 113 ScriptExecutionContext* scriptExecutionContext = getScriptExecutionConte
xt(); |
113 if (InspectorInstrumentation::consoleAgentEnabled(scriptExecutionContext
)) | 114 if (InspectorInstrumentation::consoleAgentEnabled(scriptExecutionContext
)) |
114 stackSize = maxStackSize; | 115 stackSize = maxStackSize; |
115 } | 116 } |
116 return createScriptCallStack(stackSize); | 117 return createScriptCallStack(stackSize); |
117 } | 118 } |
118 | 119 |
119 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState*) | 120 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState*) |
120 { | 121 { |
121 return createScriptCallStackForConsole(); | 122 return createScriptCallStackForConsole(); |
122 } | 123 } |
123 | 124 |
124 PassRefPtr<ScriptCallStack> createScriptCallStack(ScriptState*, size_t maxStackS
ize) | 125 PassRefPtr<ScriptCallStack> createScriptCallStack(ScriptState*, size_t maxStackS
ize) |
125 { | 126 { |
126 return createScriptCallStackForConsole(maxStackSize); | 127 return createScriptCallStackForConsole(maxStackSize); |
127 } | 128 } |
128 | 129 |
129 PassRefPtr<ScriptArguments> createScriptArguments(const v8::FunctionCallbackInfo
<v8::Value>& v8arguments, unsigned skipArgumentCount) | 130 PassRefPtr<ScriptArguments> createScriptArguments(const v8::FunctionCallbackInfo
<v8::Value>& v8arguments, unsigned skipArgumentCount) |
130 { | 131 { |
131 v8::HandleScope scope; | 132 v8::Isolate* isolate = v8arguments.GetIsolate(); |
132 v8::Local<v8::Context> context = v8::Context::GetCurrent(); | 133 v8::HandleScope scope(isolate); |
| 134 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
133 ScriptState* state = ScriptState::forContext(context); | 135 ScriptState* state = ScriptState::forContext(context); |
134 | 136 |
135 Vector<ScriptValue> arguments; | 137 Vector<ScriptValue> arguments; |
136 for (int i = skipArgumentCount; i < v8arguments.Length(); ++i) | 138 for (int i = skipArgumentCount; i < v8arguments.Length(); ++i) |
137 arguments.append(ScriptValue(v8arguments[i])); | 139 arguments.append(ScriptValue(v8arguments[i])); |
138 | 140 |
139 return ScriptArguments::create(state, arguments); | 141 return ScriptArguments::create(state, arguments); |
140 } | 142 } |
141 | 143 |
142 } // namespace WebCore | 144 } // namespace WebCore |
OLD | NEW |