Don't crash when load eval origin of a call site.

BUG=chromium:610207
LOG=N

Review-Url: https://codereview.chromium.org/1958043002
Cr-Commit-Position: refs/heads/master@{#36101}
This commit is contained in:
ishell 2016-05-09 02:00:04 -07:00 committed by Commit bot
parent aee1824adb
commit 8758245a62
2 changed files with 23 additions and 8 deletions

View File

@ -680,14 +680,16 @@ void Accessors::ScriptEvalFromFunctionNameGetter(
Handle<Object> object = Utils::OpenHandle(*info.This()); Handle<Object> object = Utils::OpenHandle(*info.This());
Handle<Script> script( Handle<Script> script(
Script::cast(Handle<JSValue>::cast(object)->value()), isolate); Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
Handle<Object> result; Handle<Object> result = isolate->factory()->undefined_value();
Handle<SharedFunctionInfo> shared( if (!script->eval_from_shared()->IsUndefined()) {
SharedFunctionInfo::cast(script->eval_from_shared())); Handle<SharedFunctionInfo> shared(
// Find the name of the function calling eval. SharedFunctionInfo::cast(script->eval_from_shared()));
if (!shared->name()->IsUndefined()) { // Find the name of the function calling eval.
result = Handle<Object>(shared->name(), isolate); if (!shared->name()->IsUndefined()) {
} else { result = Handle<Object>(shared->name(), isolate);
result = Handle<Object>(shared->inferred_name(), isolate); } else {
result = Handle<Object>(shared->inferred_name(), isolate);
}
} }
info.GetReturnValue().Set(Utils::ToLocal(result)); info.GetReturnValue().Set(Utils::ToLocal(result));
} }

View File

@ -0,0 +1,13 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Error.prepareStackTrace = function(exception, frames) {
return frames[0].getEvalOrigin();
}
try {
Realm.eval(0, "throw new Error('boom');");
} catch(e) {
print(e.stack);
}