Commit 5df3b4ab authored by jochen's avatar jochen Committed by Commit bot

Update all callsites of the TryCatch ctor to pass an Isolate

BUG=4134
R=vogelheim@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/1154423004

Cr-Commit-Position: refs/heads/master@{#28678}
parent ce2b39f2
......@@ -220,7 +220,7 @@ bool JsHttpRequestProcessor::ExecuteScript(Handle<String> script) {
// We're just about to compile the script; set up an error handler to
// catch any exceptions the script might throw.
TryCatch try_catch;
TryCatch try_catch(GetIsolate());
// Compile the script and check for errors.
Handle<Script> compiled_script = Script::Compile(script);
......@@ -281,7 +281,7 @@ bool JsHttpRequestProcessor::Process(HttpRequest* request) {
Handle<Object> request_obj = WrapRequest(request);
// Set up an exception handler before calling the Process function
TryCatch try_catch;
TryCatch try_catch(GetIsolate());
// Invoke the process function, giving the global object as 'this'
// and one argument, the request.
......
......@@ -325,7 +325,7 @@ bool ExecuteString(v8::Isolate* isolate,
bool print_result,
bool report_exceptions) {
v8::HandleScope handle_scope(isolate);
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::ScriptOrigin origin(name);
v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin);
if (script.IsEmpty()) {
......
......@@ -305,7 +305,7 @@ bool RunExtraCode(Isolate* isolate, const char* utf8_source) {
// Run custom script if provided.
base::ElapsedTimer timer;
timer.Start();
TryCatch try_catch;
TryCatch try_catch(isolate);
Local<String> source_string = String::NewFromUtf8(isolate, utf8_source);
if (try_catch.HasCaught()) return false;
ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>"));
......@@ -7473,11 +7473,12 @@ void Isolate::VisitHandlesForPartialDependence(
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current();
Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
if (obj.IsEmpty()) return;
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
Handle<String> str = obj->ToString(reinterpret_cast<v8::Isolate*>(isolate));
TryCatch try_catch(v8_isolate);
Handle<String> str = obj->ToString(v8_isolate);
if (str.IsEmpty()) return;
i::Handle<i::String> i_str = Utils::OpenHandle(*str);
length_ = v8::Utf8Length(*i_str, isolate);
......@@ -7494,11 +7495,12 @@ String::Utf8Value::~Utf8Value() {
String::Value::Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current();
Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
if (obj.IsEmpty()) return;
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
Handle<String> str = obj->ToString(reinterpret_cast<v8::Isolate*>(isolate));
TryCatch try_catch(v8_isolate);
Handle<String> str = obj->ToString(v8_isolate);
if (str.IsEmpty()) return;
length_ = str->Length();
str_ = i::NewArray<uint16_t>(length_ + 1);
......
......@@ -25,7 +25,7 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
return;
}
TryCatch try_catch;
TryCatch try_catch(isolate);
// Get the toJSONProtocol function on the event and get the JSON format.
Local<String> to_json_fun_name =
......@@ -76,7 +76,7 @@ void HandleDebugEvent(const Debug::EventDetails& event_details) {
// Ignore empty commands.
if (strlen(command) == 0) continue;
TryCatch try_catch;
TryCatch try_catch(isolate);
// Convert the debugger command to a JSON debugger request.
Handle<Value> request = Shell::DebugCommandToJSONRequest(
......
......@@ -307,7 +307,7 @@ bool Shell::ExecuteString(Isolate* isolate, Handle<String> source,
bool FLAG_debugger = false;
#endif // !V8_SHARED
HandleScope handle_scope(isolate);
TryCatch try_catch;
TryCatch try_catch(isolate);
options.script_executed = true;
if (FLAG_debugger) {
// When debugging make exceptions appear to be uncaught.
......@@ -352,7 +352,7 @@ bool Shell::ExecuteString(Isolate* isolate, Handle<String> source,
}
#if !defined(V8_SHARED)
} else {
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, utility_context_);
v8::Context::Scope context_scope(context);
......@@ -571,7 +571,7 @@ void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
// Explicitly catch potential exceptions in toString().
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
Handle<String> str_obj = args[i]->ToString(args.GetIsolate());
if (try_catch.HasCaught()) {
try_catch.ReThrow();
......
......@@ -200,7 +200,7 @@ MaybeHandle<Object> Execution::TryCall(Handle<JSFunction> func,
// creating message objects during stack overflow we shouldn't
// capture messages.
{
v8::TryCatch catcher;
v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate));
catcher.SetVerbose(false);
catcher.SetCaptureMessage(false);
......
......@@ -844,7 +844,7 @@ MaybeHandle<JSArray> LiveEdit::GatherCompileInfo(Handle<Script> script,
{
// Creating verbose TryCatch from public API is currently the only way to
// force code save location. We do not use this the object directly.
v8::TryCatch try_catch;
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
try_catch.SetVerbose(true);
// A logical 'try' section.
......
......@@ -112,7 +112,7 @@ void MessageHandler::ReportMessage(Isolate* isolate, MessageLocation* loc,
Handle<Object> callback_data(listener.get(1), isolate);
{
// Do not allow exceptions to propagate.
v8::TryCatch try_catch;
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
callback(api_message_obj, callback_data->IsUndefined()
? api_exception_obj
: v8::Utils::ToLocal(callback_data));
......
......@@ -58,7 +58,7 @@ RUNTIME_FUNCTION(Runtime_DeliverObservationChangeRecords) {
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, argument, 1);
v8::TryCatch catcher;
v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate));
// We should send a message on uncaught exception thrown during
// Object.observe delivery while not interrupting further delivery, thus
// we make a call inside a verbose TryCatch.
......
......@@ -63,7 +63,7 @@ class FunctionTester : public InitializedHandleScope {
}
void CheckThrows(Handle<Object> a, Handle<Object> b) {
TryCatch try_catch;
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a, b);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
......@@ -73,7 +73,7 @@ class FunctionTester : public InitializedHandleScope {
v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a,
Handle<Object> b) {
TryCatch try_catch;
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a, b);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
......
......@@ -552,7 +552,7 @@ THREADED_TEST(AccessorPropertyCrossContext) {
v8::Handle<v8::Function> fun = v8::Function::New(isolate, check_contexts);
LocalContext switch_context;
switch_context->Global()->Set(v8_str("fun"), fun);
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
expected_current_context = env.local();
expected_calling_context = switch_context.local();
CompileRun(
......
This diff is collapsed.
......@@ -211,7 +211,7 @@ static int SetScriptBreakPointByIdFromJS(v8::Isolate* isolate, int script_id,
}
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::Handle<v8::String> str =
v8::String::NewFromUtf8(isolate, buffer.start());
v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
......@@ -240,7 +240,7 @@ static int SetScriptBreakPointByNameFromJS(v8::Isolate* isolate,
}
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::Handle<v8::String> str =
v8::String::NewFromUtf8(isolate, buffer.start());
v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
......@@ -4023,7 +4023,7 @@ TEST(EvalJSInDebugEventListenerOnNativeReThrownException) {
// ReThrow native error
{
v8::TryCatch tryCatch;
v8::TryCatch tryCatch(env->GetIsolate());
env->GetIsolate()->ThrowException(v8::Exception::TypeError(
v8::String::NewFromUtf8(env->GetIsolate(), "Type error")));
CHECK(tryCatch.HasCaught());
......@@ -5602,7 +5602,7 @@ static void CheckDataParameter(
CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
for (int i = 0; i < 3; i++) {
v8::TryCatch catcher;
v8::TryCatch catcher(args.GetIsolate());
CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
CHECK(catcher.HasCaught());
CHECK(catcher.Exception()->IsString());
......@@ -7267,7 +7267,7 @@ static void DebugEventStepNext(
static void RunScriptInANewCFrame(const char* source) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
CompileRun(source);
CHECK(try_catch.HasCaught());
}
......@@ -7447,7 +7447,7 @@ TEST(DebugBreakOffThreadTerminate) {
v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
TerminationThread terminator(isolate);
terminator.Start();
v8::TryCatch try_catch;
v8::TryCatch try_catch(env->GetIsolate());
v8::Debug::DebugBreak(isolate);
CompileRun("while (true);");
CHECK(try_catch.HasTerminated());
......@@ -7463,7 +7463,7 @@ static void DebugEventExpectNoException(
static void TryCatchWrappedThrowCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
CompileRun("throw 'rejection';");
CHECK(try_catch.HasCaught());
}
......
......@@ -143,7 +143,7 @@ void DeclarationContext::Check(const char* source,
// to avoid that.
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
HandleScope scope(CcTest::isolate());
TryCatch catcher;
TryCatch catcher(CcTest::isolate());
catcher.SetVerbose(true);
Local<Script> script =
Script::Compile(String::NewFromUtf8(CcTest::isolate(), source));
......@@ -567,7 +567,7 @@ class SimpleContext {
Expectations expectations,
v8::Handle<Value> value = Local<Value>()) {
HandleScope scope(context_->GetIsolate());
TryCatch catcher;
TryCatch catcher(context_->GetIsolate());
catcher.SetVerbose(true);
Local<Script> script =
Script::Compile(String::NewFromUtf8(context_->GetIsolate(), source));
......
......@@ -37,7 +37,7 @@ TEST(StrictUndeclaredGlobalVariable) {
HandleScope scope(CcTest::isolate());
v8::Local<v8::String> var_name = v8_str("x");
LocalContext context;
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
v8::Local<v8::Script> script = v8_compile("\"use strict\"; x = 42;");
v8::Handle<v8::Object> proto = v8::Object::New(CcTest::isolate());
v8::Handle<v8::Object> global =
......
......@@ -5346,7 +5346,7 @@ TEST(PreprocessStackTrace) {
FLAG_gc_interval = -1;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
CompileRun("throw new Error();");
CHECK(try_catch.HasCaught());
Isolate* isolate = CcTest::i_isolate();
......@@ -5420,7 +5420,7 @@ TEST(Regress1878) {
v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function());
CcTest::global()->Set(v8_str("InternalArray"), constructor);
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
CompileRun(
"var a = Array();"
......
......@@ -482,7 +482,7 @@ TEST(EquivalenceOfLoggingAndTraversal) {
i::Vector<const char> source = TestSources::GetScriptsSource();
v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
isolate, source.start(), v8::String::kNormalString, source.length());
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::Handle<v8::Script> script = CompileWithOrigin(source_str, "");
if (script.IsEmpty()) {
v8::String::Utf8Value exception(try_catch.Exception());
......
......@@ -1685,7 +1685,7 @@ TEST(StrictOctal) {
v8::HandleScope scope(CcTest::isolate());
v8::Context::Scope context_scope(
v8::Context::New(CcTest::isolate()));
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
const char* script =
"\"use strict\"; \n"
"a = function() { \n"
......@@ -6224,7 +6224,7 @@ TEST(StrongModeFreeVariablesDeclaredByPreviousScript) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
// Introduce a bunch of variables, in all language modes.
const char* script1 =
......@@ -6283,7 +6283,7 @@ TEST(StrongModeFreeVariablesDeclaredByLanguage) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
const char* script1 =
"\"use strong\"; \n"
......@@ -6299,7 +6299,7 @@ TEST(StrongModeFreeVariablesDeclaredInGlobalPrototype) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
const char* script1 = "this.__proto__.my_var = 0;\n";
CompileRun(v8_str(script1));
......@@ -6318,7 +6318,7 @@ TEST(StrongModeFreeVariablesNotDeclared) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
v8::TryCatch try_catch;
v8::TryCatch try_catch(CcTest::isolate());
// Test that referencing unintroduced variables in sloppy mode is ok.
const char* script1 =
......@@ -6335,7 +6335,7 @@ TEST(StrongModeFreeVariablesNotDeclared) {
"if (false) { \n"
" not_there2; \n"
"} \n";
v8::TryCatch try_catch2;
v8::TryCatch try_catch2(CcTest::isolate());
v8::Script::Compile(v8_str(script2));
CHECK(try_catch2.HasCaught());
v8::String::Utf8Value exception(try_catch2.Exception());
......@@ -6356,7 +6356,7 @@ TEST(StrongModeFreeVariablesNotDeclared) {
" not_there3; \n"
" } \n"
"})(); \n";
v8::TryCatch try_catch2;
v8::TryCatch try_catch2(CcTest::isolate());
v8::Script::Compile(v8_str(script3));
CHECK(try_catch2.HasCaught());
v8::String::Utf8Value exception(try_catch2.Exception());
......
......@@ -1222,7 +1222,7 @@ UNINITIALIZED_TEST(OneByteArrayJoin) {
// summing the lengths of the strings (as Smis) overflows and wraps.
LocalContext context(isolate);
v8::HandleScope scope(isolate);
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
CHECK(CompileRun(
"var two_14 = Math.pow(2, 14);"
"var two_17 = Math.pow(2, 17);"
......
......@@ -61,7 +61,7 @@ void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"function f() {"
......@@ -86,7 +86,7 @@ void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"var term = true;"
......@@ -217,7 +217,7 @@ void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(
v8::String::NewFromUtf8(args.GetIsolate(),
......@@ -275,7 +275,7 @@ v8::Persistent<v8::String> reenter_script_1;
v8::Persistent<v8::String> reenter_script_2;
void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
v8::Isolate* isolate = args.GetIsolate();
CHECK(!v8::V8::IsExecutionTerminating(isolate));
v8::Local<v8::String> script =
......@@ -328,7 +328,7 @@ TEST(TerminateAndReenterFromThreadItself) {
void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(args.GetIsolate());
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"var term = true;"
......@@ -426,7 +426,7 @@ TEST(PostponeTerminateException) {
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
static const char* terminate_and_loop =
"terminate(); for (var i = 0; i < 10000; i++);";
......@@ -504,7 +504,7 @@ TEST(TerminationInInnerTryCall) {
v8::Context::New(CcTest::isolate(), NULL, global_template);
v8::Context::Scope context_scope(context);
{
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
CompileRun("inner_try_call_terminate()");
CHECK(try_catch.HasTerminated());
}
......@@ -522,7 +522,7 @@ TEST(TerminateAndTryCall) {
v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(isolate));
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
CHECK(!v8::V8::IsExecutionTerminating(isolate));
// Terminate execution has been triggered inside TryCall, but re-requested
// to trigger later.
......
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