Revision: 16955
Author: [email protected]
Date: Thu Sep 26 07:37:59 2013 UTC
Log: add isolate parameter to ThrowException
[email protected]
BUG=
Review URL: https://codereview.chromium.org/24538002
http://code.google.com/p/v8/source/detail?r=16955
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/samples/lineprocessor.cc
/branches/bleeding_edge/samples/shell.cc
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/d8-posix.cc
/branches/bleeding_edge/src/extensions/externalize-string-extension.cc
/branches/bleeding_edge/test/cctest/test-accessors.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Tue Sep 24 16:51:43 2013 UTC
+++ /branches/bleeding_edge/include/v8.h Thu Sep 26 07:37:59 2013 UTC
@@ -3791,12 +3791,7 @@
typedef void (*MessageCallback)(Handle<Message> message, Handle<Value>
error);
-/**
- * Schedules an exception to be thrown when returning to JavaScript. When
an
- * exception has been scheduled it is illegal to invoke any JavaScript
- * operation; the caller must return immediately and only after the
exception
- * has been handled does it become legal to invoke JavaScript operations.
- */
+// TODO(dcarney): remove. Use Isolate::ThrowException instead.
Handle<Value> V8_EXPORT ThrowException(Handle<Value> exception);
/**
@@ -4051,6 +4046,14 @@
/** Returns the last entered context. */
Local<Context> GetEnteredContext();
+ /**
+ * Schedules an exception to be thrown when returning to JavaScript.
When an
+ * exception has been scheduled it is illegal to invoke any JavaScript
+ * operation; the caller must return immediately and only after the
exception
+ * has been handled does it become legal to invoke JavaScript operations.
+ */
+ Local<Value> V8_EXPORT ThrowException(Local<Value> exception);
+
/**
* Allows the host application to group objects together. If one
* object in the group is alive, all objects in the group are alive.
=======================================
--- /branches/bleeding_edge/samples/lineprocessor.cc Mon Sep 23 11:25:52
2013 UTC
+++ /branches/bleeding_edge/samples/lineprocessor.cc Thu Sep 26 07:37:59
2013 UTC
@@ -417,7 +417,7 @@
// function is called. Reads a string from standard input and returns.
void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() > 0) {
- v8::ThrowException(v8::String::New("Unexpected arguments"));
+ args.GetIsolate()->ThrowException(v8::String::New("Unexpected
arguments"));
return;
}
args.GetReturnValue().Set(ReadLine());
=======================================
--- /branches/bleeding_edge/samples/shell.cc Thu Jul 11 09:58:54 2013 UTC
+++ /branches/bleeding_edge/samples/shell.cc Thu Sep 26 07:37:59 2013 UTC
@@ -140,17 +140,20 @@
// the argument into a JavaScript string.
void Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 1) {
- v8::ThrowException(v8::String::New("Bad parameters"));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("Bad parameters"));
return;
}
v8::String::Utf8Value file(args[0]);
if (*file == NULL) {
- v8::ThrowException(v8::String::New("Error loading file"));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("Error loading file"));
return;
}
v8::Handle<v8::String> source = ReadFile(*file);
if (source.IsEmpty()) {
- v8::ThrowException(v8::String::New("Error loading file"));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("Error loading file"));
return;
}
args.GetReturnValue().Set(source);
@@ -165,12 +168,14 @@
v8::HandleScope handle_scope(args.GetIsolate());
v8::String::Utf8Value file(args[i]);
if (*file == NULL) {
- v8::ThrowException(v8::String::New("Error loading file"));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("Error loading file"));
return;
}
v8::Handle<v8::String> source = ReadFile(*file);
if (source.IsEmpty()) {
- v8::ThrowException(v8::String::New("Error loading file"));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("Error loading file"));
return;
}
if (!ExecuteString(args.GetIsolate(),
@@ -178,7 +183,8 @@
v8::String::New(*file),
false,
false)) {
- v8::ThrowException(v8::String::New("Error executing file"));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("Error executing file"));
return;
}
}
=======================================
--- /branches/bleeding_edge/src/api.cc Tue Sep 24 16:51:43 2013 UTC
+++ /branches/bleeding_edge/src/api.cc Thu Sep 26 07:37:59 2013 UTC
@@ -473,16 +473,7 @@
v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
- i::Isolate* isolate = i::Isolate::Current();
- ENTER_V8(isolate);
- // If we're passed an empty handle, we throw an undefined exception
- // to deal more gracefully with out of memory situations.
- if (value.IsEmpty()) {
- isolate->ScheduleThrow(isolate->heap()->undefined_value());
- } else {
- isolate->ScheduleThrow(*Utils::OpenHandle(*value));
- }
- return v8::Undefined();
+ return v8::Isolate::GetCurrent()->ThrowException(value);
}
@@ -1926,7 +1917,7 @@
isolate_->RestorePendingMessageFromTryCatch(this);
}
isolate_->UnregisterTryCatchHandler(this);
- v8::ThrowException(exc);
+ reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
ASSERT(!isolate_->thread_local_top()->rethrowing_message_);
} else {
isolate_->UnregisterTryCatchHandler(this);
@@ -6359,6 +6350,20 @@
if (last.is_null()) return Local<Context>();
return Utils::ToLocal(i::Handle<i::Context>::cast(last));
}
+
+
+v8::Local<Value> Isolate::ThrowException(v8::Local<v8::Value> value) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ ENTER_V8(isolate);
+ // If we're passed an empty handle, we throw an undefined exception
+ // to deal more gracefully with out of memory situations.
+ if (value.IsEmpty()) {
+ isolate->ScheduleThrow(isolate->heap()->undefined_value());
+ } else {
+ isolate->ScheduleThrow(*Utils::OpenHandle(*value));
+ }
+ return v8::Undefined();
+}
void Isolate::SetObjectGroupId(const Persistent<Value>& object,
=======================================
--- /branches/bleeding_edge/src/d8-posix.cc Mon Jul 29 12:12:39 2013 UTC
+++ /branches/bleeding_edge/src/d8-posix.cc Thu Sep 26 07:37:59 2013 UTC
@@ -245,7 +245,8 @@
if (args[3]->IsNumber()) {
*total_timeout = args[3]->Int32Value();
} else {
- ThrowException(String::New("system: Argument 4 must be a number"));
+ args.GetIsolate()->ThrowException(
+ String::New("system: Argument 4 must be a number"));
return false;
}
}
@@ -253,7 +254,8 @@
if (args[2]->IsNumber()) {
*read_timeout = args[2]->Int32Value();
} else {
- ThrowException(String::New("system: Argument 3 must be a number"));
+ args.GetIsolate()->ThrowException(
+ String::New("system: Argument 3 must be a number"));
return false;
}
}
@@ -456,7 +458,8 @@
Handle<Array> command_args;
if (args.Length() > 1) {
if (!args[1]->IsArray()) {
- ThrowException(String::New("system: Argument 2 must be an array"));
+ args.GetIsolate()->ThrowException(
+ String::New("system: Argument 2 must be an array"));
return;
}
command_args = Handle<Array>::Cast(args[1]);
@@ -464,11 +467,13 @@
command_args = Array::New(0);
}
if (command_args->Length() > ExecArgs::kMaxArgs) {
- ThrowException(String::New("Too many arguments to system()"));
+ args.GetIsolate()->ThrowException(
+ String::New("Too many arguments to system()"));
return;
}
if (args.Length() < 1) {
- ThrowException(String::New("Too few arguments to system()"));
+ args.GetIsolate()->ThrowException(
+ String::New("Too few arguments to system()"));
return;
}
@@ -483,11 +488,13 @@
int stdout_fds[2];
if (pipe(exec_error_fds) != 0) {
- ThrowException(String::New("pipe syscall failed."));
+ args.GetIsolate()->ThrowException(
+ String::New("pipe syscall failed."));
return;
}
if (pipe(stdout_fds) != 0) {
- ThrowException(String::New("pipe syscall failed."));
+ args.GetIsolate()->ThrowException(
+ String::New("pipe syscall failed."));
return;
}
@@ -531,17 +538,17 @@
void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>&
args) {
if (args.Length() != 1) {
const char* message = "chdir() takes one argument";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
String::Utf8Value directory(args[0]);
if (*directory == NULL) {
const char* message = "os.chdir(): String conversion of argument
failed.";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
if (chdir(*directory) != 0) {
- ThrowException(String::New(strerror(errno)));
+ args.GetIsolate()->ThrowException(String::New(strerror(errno)));
return;
}
}
@@ -550,7 +557,7 @@
void Shell::SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 1) {
const char* message = "umask() takes one argument";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
if (args[0]->IsNumber()) {
@@ -560,7 +567,7 @@
return;
} else {
const char* message = "umask() argument must be numeric";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
}
@@ -616,18 +623,18 @@
mask = args[1]->Int32Value();
} else {
const char* message = "mkdirp() second argument must be numeric";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
} else if (args.Length() != 1) {
const char* message = "mkdirp() takes one or two arguments";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
String::Utf8Value directory(args[0]);
if (*directory == NULL) {
const char* message = "os.mkdirp(): String conversion of argument
failed.";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
mkdirp(*directory, mask);
@@ -637,13 +644,13 @@
void Shell::RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>&
args) {
if (args.Length() != 1) {
const char* message = "rmdir() takes one or two arguments";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
String::Utf8Value directory(args[0]);
if (*directory == NULL) {
const char* message = "os.rmdir(): String conversion of argument
failed.";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
rmdir(*directory);
@@ -653,7 +660,7 @@
void Shell::SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>&
args) {
if (args.Length() != 2) {
const char* message = "setenv() takes two arguments";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
String::Utf8Value var(args[0]);
@@ -661,13 +668,13 @@
if (*var == NULL) {
const char* message =
"os.setenv(): String conversion of variable name failed.";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
if (*value == NULL) {
const char* message =
"os.setenv(): String conversion of variable contents failed.";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
setenv(*var, *value, 1);
@@ -677,14 +684,14 @@
void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>&
args) {
if (args.Length() != 1) {
const char* message = "unsetenv() takes one argument";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
String::Utf8Value var(args[0]);
if (*var == NULL) {
const char* message =
"os.setenv(): String conversion of variable name failed.";
- ThrowException(String::New(message));
+ args.GetIsolate()->ThrowException(String::New(message));
return;
}
unsetenv(*var);
=======================================
--- /branches/bleeding_edge/src/extensions/externalize-string-extension.cc
Tue Sep 10 14:30:36 2013 UTC
+++ /branches/bleeding_edge/src/extensions/externalize-string-extension.cc
Thu Sep 26 07:37:59 2013 UTC
@@ -75,7 +75,7 @@
void ExternalizeStringExtension::Externalize(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() < 1 || !args[0]->IsString()) {
- v8::ThrowException(v8::String::New(
+ args.GetIsolate()->ThrowException(v8::String::New(
"First parameter to externalizeString() must be a string."));
return;
}
@@ -84,7 +84,7 @@
if (args[1]->IsBoolean()) {
force_two_byte = args[1]->BooleanValue();
} else {
- v8::ThrowException(v8::String::New(
+ args.GetIsolate()->ThrowException(v8::String::New(
"Second parameter to externalizeString() must be a boolean."));
return;
}
@@ -92,7 +92,7 @@
bool result = false;
Handle<String> string = Utils::OpenHandle(*args[0].As<v8::String>());
if (string->IsExternalString()) {
- v8::ThrowException(v8::String::New(
+ args.GetIsolate()->ThrowException(v8::String::New(
"externalizeString() can't externalize twice."));
return;
}
@@ -120,7 +120,8 @@
if (!result) delete resource;
}
if (!result) {
- v8::ThrowException(v8::String::New("externalizeString() failed."));
+ args.GetIsolate()->ThrowException(
+ v8::String::New("externalizeString() failed."));
return;
}
}
@@ -129,7 +130,7 @@
void ExternalizeStringExtension::IsAscii(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 1 || !args[0]->IsString()) {
- v8::ThrowException(v8::String::New(
+ args.GetIsolate()->ThrowException(v8::String::New(
"isAsciiString() requires a single string argument."));
return;
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-accessors.cc Thu Sep 19
09:46:15 2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-accessors.cc Thu Sep 26
07:37:59 2013 UTC
@@ -405,14 +405,14 @@
Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
- v8::ThrowException(v8_str("g"));
+ info.GetIsolate()->ThrowException(v8_str("g"));
}
static void ThrowingSetAccessor(Local<String> name,
Local<Value> value,
const v8::PropertyCallbackInfo<void>&
info) {
- v8::ThrowException(value);
+ info.GetIsolate()->ThrowException(value);
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Tue Sep 24 16:51:43
2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Thu Sep 26 07:37:59
2013 UTC
@@ -2451,7 +2451,7 @@
Local<String> key,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
- info.GetReturnValue().Set(v8::ThrowException(key));
+ info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key));
}
@@ -2459,7 +2459,7 @@
Local<String> key,
Local<Value>,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::ThrowException(key);
+ info.GetIsolate()->ThrowException(key);
info.GetReturnValue().SetUndefined(); // not the same as empty handle
}
@@ -4375,7 +4375,7 @@
void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
- v8::ThrowException(v8_str("konto"));
+ args.GetIsolate()->ThrowException(v8_str("konto"));
}
@@ -4658,7 +4658,7 @@
int count = args[0]->Int32Value();
int cInterval = args[2]->Int32Value();
if (count == 0) {
- v8::ThrowException(v8_str("FromC"));
+ args.GetIsolate()->ThrowException(v8_str("FromC"));
return;
} else {
Local<v8::Object> global =
@@ -4798,7 +4798,7 @@
void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
CHECK_EQ(1, args.Length());
- v8::ThrowException(args[0]);
+ args.GetIsolate()->ThrowException(args[0]);
}
@@ -4896,7 +4896,7 @@
CHECK(try_catch.HasCaught());
try_catch.ReThrow();
} else {
- v8::ThrowException(v8_str("back"));
+ CcTest::isolate()->ThrowException(v8_str("back"));
}
}
@@ -11259,7 +11259,7 @@
void ThrowingDirectApiCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::ThrowException(v8_str("g"));
+ args.GetIsolate()->ThrowException(v8_str("g"));
}
@@ -11327,7 +11327,7 @@
void ThrowingDirectGetterCallback(
Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::ThrowException(v8_str("g"));
+ info.GetIsolate()->ThrowException(v8_str("g"));
}
@@ -11938,7 +11938,7 @@
info.GetReturnValue().Set(call_ic_function3);
}
if (interceptor_ic_exception_get_count == 20) {
- v8::ThrowException(v8_num(42));
+ info.GetIsolate()->ThrowException(v8_num(42));
return;
}
}
@@ -11983,7 +11983,7 @@
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (++interceptor_ic_exception_set_count > 20) {
- v8::ThrowException(v8_num(42));
+ info.GetIsolate()->ThrowException(v8_num(42));
}
}
@@ -12055,7 +12055,7 @@
static void ThrowingGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>&
info) {
ApiTestFuzzer::Fuzz();
- ThrowException(Handle<Value>());
+ info.GetIsolate()->ThrowException(Handle<Value>());
info.GetReturnValue().SetUndefined();
}
@@ -12140,7 +12140,7 @@
static void ThrowViaApi(Handle<Message> message, Handle<Value> data) {
- if (--call_depth) ThrowException(v8_str("ThrowViaApi"));
+ if (--call_depth)
CcTest::isolate()->ThrowException(v8_str("ThrowViaApi"));
}
@@ -12499,12 +12499,12 @@
static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(v8::Locker::IsLocked(CcTest::isolate()));
+ CHECK(v8::Locker::IsLocked(args.GetIsolate()));
ApiTestFuzzer::Fuzz();
- v8::Unlocker unlocker(CcTest::isolate());
+ v8::Unlocker unlocker(args.GetIsolate());
const char* code = "throw 7;";
{
- v8::Locker nested_locker(CcTest::isolate());
+ v8::Locker nested_locker(args.GetIsolate());
v8::HandleScope scope(args.GetIsolate());
v8::Handle<Value> exception;
{ v8::TryCatch try_catch;
@@ -12516,7 +12516,7 @@
// when the TryCatch is destroyed.
exception = Local<Value>::New(try_catch.Exception());
}
- v8::ThrowException(exception);
+ args.GetIsolate()->ThrowException(exception);
}
}
@@ -20341,7 +20341,8 @@
Local<v8::Value> data) {
access_check_fail_thrown = true;
i::PrintF("Access check failed. Error thrown.\n");
- v8::ThrowException(v8::Exception::Error(v8_str("cross context")));
+ CcTest::isolate()->ThrowException(
+ v8::Exception::Error(v8_str("cross context")));
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.