Commit 4fbffba4 authored by jgruber's avatar jgruber Committed by Commit bot

Don't call into JS from within stack trace generation

Calling into JS from stack trace generation becomes an issue during
stack overflows: we'd detect a stack overflow, attempt to create an
exception, call into JS, detect a stack overflow, and repeat.

R=yangguo@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2147193002
Cr-Commit-Position: refs/heads/master@{#37837}
parent 36332822
......@@ -403,6 +403,8 @@ class StackTraceHelper {
Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
Handle<Object> caller) {
DisallowJavascriptExecution no_js(this);
// Get stack trace limit.
Handle<JSObject> error = error_function();
Handle<String> stackTraceLimit =
......@@ -738,6 +740,7 @@ int PositionFromStackTrace(Handle<FixedArray> elements, int index) {
Handle<JSArray> Isolate::CaptureCurrentStackTrace(
int frame_limit, StackTrace::StackTraceOptions options) {
DisallowJavascriptExecution no_js(this);
CaptureStackTraceHelper helper(this, options);
// Ensure no negative values.
......@@ -921,6 +924,7 @@ bool Isolate::MayAccess(Handle<Context> accessing_context,
Object* Isolate::StackOverflow() {
DisallowJavascriptExecution no_js(this);
HandleScope scope(this);
// At this point we cannot create an Error object using its javascript
// constructor. Instead, we copy the pre-constructed boilerplate and
......
......@@ -246,6 +246,7 @@ function ScriptLocationFromPosition(position,
* deprecated //@ sourceURL comment otherwise.
*/
function ScriptNameOrSourceURL() {
// Keep in sync with Script::GetNameOrSourceURL.
if (this.source_url) return this.source_url;
return this.name;
}
......
......@@ -12822,22 +12822,13 @@ int Script::GetLineNumber(int code_pos) {
Handle<Object> Script::GetNameOrSourceURL(Handle<Script> script) {
Isolate* isolate = script->GetIsolate();
Handle<String> name_or_source_url_key =
isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("nameOrSourceURL"));
Handle<JSObject> script_wrapper = Script::GetWrapper(script);
Handle<Object> property =
JSReceiver::GetProperty(script_wrapper, name_or_source_url_key)
.ToHandleChecked();
DCHECK(property->IsJSFunction());
Handle<Object> result;
// Do not check against pending exception, since this function may be called
// when an exception has already been pending.
if (!Execution::TryCall(isolate, property, script_wrapper, 0, NULL)
.ToHandle(&result)) {
return isolate->factory()->undefined_value();
// Keep in sync with ScriptNameOrSourceURL in messages.js.
if (!script->source_url()->IsUndefined(isolate)) {
return handle(script->source_url(), isolate);
}
return result;
return handle(script->name(), isolate);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment