Remove ENTER_V8 from small API functions that do not need access to

V8's heap or only need read access.

This means that IsDeadCeck and EnsureInitialized could sometimes be
called without having already entered the VM.  To simplify things,
this is made always the case.  A couple of error callbacks do not need
to leave V8 because they haven't entered.

Consistently enter V8 after LOG_API (since LOG_API is sometimes before
EnsureInitialized or IsDeadCheck).

This all should have no effect unless V8 is built with
ENABLE_HEAP_PROTECTION and run with --protect-heap.

Review URL: http://codereview.chromium.org/56211

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1672 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8947c308
......@@ -140,10 +140,7 @@ void V8::SetFatalErrorHandler(FatalErrorCallback that) {
bool Utils::ReportApiFailure(const char* location, const char* message) {
FatalErrorCallback callback = GetFatalErrorHandler();
{
LEAVE_V8;
callback(location, message);
}
callback(location, message);
has_shut_down = true;
return false;
}
......@@ -163,20 +160,14 @@ static inline bool ApiCheck(bool condition,
static bool ReportV8Dead(const char* location) {
FatalErrorCallback callback = GetFatalErrorHandler();
{
LEAVE_V8;
callback(location, "V8 is no longer usable");
}
callback(location, "V8 is no longer usable");
return true;
}
static bool ReportEmptyHandle(const char* location) {
FatalErrorCallback callback = GetFatalErrorHandler();
{
LEAVE_V8;
callback(location, "Reading from empty handle");
}
callback(location, "Reading from empty handle");
return true;
}
......@@ -214,7 +205,6 @@ static i::StringInputBuffer write_input_buffer;
static void EnsureInitialized(const char* location) {
ENTER_V8;
if (IsDeadCheck(location)) return;
ApiCheck(v8::V8::Initialize(), location, "Error initializing V8");
}
......@@ -234,7 +224,6 @@ void ImplementationUtilities::ZapHandleRange(void** begin, void** end) {
v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() {
ENTER_V8;
if (IsDeadCheck("v8::Undefined()")) return v8::Handle<v8::Primitive>();
EnsureInitialized("v8::Undefined()");
return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::undefined_value()));
......@@ -242,7 +231,6 @@ v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() {
v8::Handle<v8::Primitive> ImplementationUtilities::Null() {
ENTER_V8;
if (IsDeadCheck("v8::Null()")) return v8::Handle<v8::Primitive>();
EnsureInitialized("v8::Null()");
return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::null_value()));
......@@ -250,7 +238,6 @@ v8::Handle<v8::Primitive> ImplementationUtilities::Null() {
v8::Handle<v8::Boolean> ImplementationUtilities::True() {
ENTER_V8;
if (IsDeadCheck("v8::True()")) return v8::Handle<v8::Boolean>();
EnsureInitialized("v8::True()");
return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::true_value()));
......@@ -258,7 +245,6 @@ v8::Handle<v8::Boolean> ImplementationUtilities::True() {
v8::Handle<v8::Boolean> ImplementationUtilities::False() {
ENTER_V8;
if (IsDeadCheck("v8::False()")) return v8::Handle<v8::Boolean>();
EnsureInitialized("v8::False()");
return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::false_value()));
......@@ -276,8 +262,8 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
ENTER_V8;
if (IsDeadCheck("v8::ThrowException()")) return v8::Handle<Value>();
ENTER_V8;
// If we're passed an empty handle, we throw an undefined exception
// to deal more gracefully with out of memory situations.
if (value.IsEmpty()) {
......@@ -362,9 +348,8 @@ bool SetResourceConstraints(ResourceConstraints* constraints) {
void** V8::GlobalizeReference(void** obj) {
ENTER_V8;
LOG_API("Persistent::New");
if (IsDeadCheck("V8::Persistent::New")) return NULL;
LOG_API("Persistent::New");
i::Handle<i::Object> result =
i::GlobalHandles::Create(*reinterpret_cast<i::Object**>(obj));
return reinterpret_cast<void**>(result.location());
......@@ -434,8 +419,8 @@ void** v8::HandleScope::CreateHandle(void* value) {
void Context::Enter() {
ENTER_V8;
if (IsDeadCheck("v8::Context::Enter()")) return;
ENTER_V8;
i::Handle<i::Context> env = Utils::OpenHandle(this);
thread_local.EnterContext(env);
......@@ -487,8 +472,8 @@ void** v8::HandleScope::RawClose(void** value) {
// NeanderObject constructor. When you add one to the site calling the
// constructor you should check that you ensured the VM was not dead first.
NeanderObject::NeanderObject(int size) {
ENTER_V8;
EnsureInitialized("v8::Nowhere");
ENTER_V8;
value_ = i::Factory::NewNeanderObject();
i::Handle<i::FixedArray> elements = i::Factory::NewFixedArray(size);
value_->set_elements(*elements);
......@@ -552,8 +537,8 @@ static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
void Template::Set(v8::Handle<String> name, v8::Handle<Data> value,
v8::PropertyAttribute attribute) {
ENTER_V8;
if (IsDeadCheck("v8::Template::SetProperty()")) return;
ENTER_V8;
HandleScope scope;
i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list());
if (list->IsUndefined()) {
......@@ -576,10 +561,10 @@ static void InitializeFunctionTemplate(
Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::PrototypeTemplate()")) {
return Local<ObjectTemplate>();
}
ENTER_V8;
i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template());
if (result->IsUndefined()) {
result = Utils::OpenHandle(*ObjectTemplate::New());
......@@ -590,8 +575,8 @@ Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::Inherit()")) return;
ENTER_V8;
Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
}
......@@ -603,9 +588,9 @@ static int next_serial_number = 0;
Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
v8::Handle<Value> data, v8::Handle<Signature> signature) {
ENTER_V8;
EnsureInitialized("v8::FunctionTemplate::New()");
LOG_API("FunctionTemplate::New");
ENTER_V8;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
i::Handle<i::FunctionTemplateInfo> obj =
......@@ -627,9 +612,9 @@ Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
int argc, Handle<FunctionTemplate> argv[]) {
ENTER_V8;
EnsureInitialized("v8::Signature::New()");
LOG_API("Signature::New");
ENTER_V8;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::SIGNATURE_INFO_TYPE);
i::Handle<i::SignatureInfo> obj =
......@@ -654,9 +639,9 @@ Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) {
Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) {
ENTER_V8;
EnsureInitialized("v8::TypeSwitch::New()");
LOG_API("TypeSwitch::New");
ENTER_V8;
i::Handle<i::FixedArray> vector = i::Factory::NewFixedArray(argc);
for (int i = 0; i < argc; i++)
vector->set(i, *Utils::OpenHandle(*types[i]));
......@@ -684,8 +669,8 @@ int TypeSwitch::match(v8::Handle<Value> value) {
void FunctionTemplate::SetCallHandler(InvocationCallback callback,
v8::Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return;
ENTER_V8;
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE);
......@@ -705,10 +690,10 @@ void FunctionTemplate::AddInstancePropertyAccessor(
v8::Handle<Value> data,
v8::AccessControl settings,
v8::PropertyAttribute attributes) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::AddInstancePropertyAccessor()")) {
return;
}
ENTER_V8;
HandleScope scope;
i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo();
ASSERT(getter != NULL);
......@@ -733,10 +718,10 @@ void FunctionTemplate::AddInstancePropertyAccessor(
Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::InstanceTemplate()")
|| EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
return Local<ObjectTemplate>();
ENTER_V8;
if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) {
Local<ObjectTemplate> templ =
ObjectTemplate::New(v8::Handle<FunctionTemplate>(this));
......@@ -749,15 +734,15 @@ Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
void FunctionTemplate::SetClassName(Handle<String> name) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::SetClassName()")) return;
ENTER_V8;
Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
}
void FunctionTemplate::SetHiddenPrototype(bool value) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::SetHiddenPrototype()")) return;
ENTER_V8;
Utils::OpenHandle(this)->set_hidden_prototype(value);
}
......@@ -769,10 +754,10 @@ void FunctionTemplate::SetNamedInstancePropertyHandler(
NamedPropertyDeleter remover,
NamedPropertyEnumerator enumerator,
Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
return;
}
ENTER_V8;
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
......@@ -796,11 +781,11 @@ void FunctionTemplate::SetIndexedInstancePropertyHandler(
IndexedPropertyDeleter remover,
IndexedPropertyEnumerator enumerator,
Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck(
"v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
return;
}
ENTER_V8;
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE);
......@@ -820,10 +805,10 @@ void FunctionTemplate::SetIndexedInstancePropertyHandler(
void FunctionTemplate::SetInstanceCallAsFunctionHandler(
InvocationCallback callback,
Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
return;
}
ENTER_V8;
HandleScope scope;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE);
......@@ -846,10 +831,10 @@ Local<ObjectTemplate> ObjectTemplate::New() {
Local<ObjectTemplate> ObjectTemplate::New(
v8::Handle<FunctionTemplate> constructor) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::New()")) return Local<ObjectTemplate>();
EnsureInitialized("v8::ObjectTemplate::New()");
LOG_API("ObjectTemplate::New");
ENTER_V8;
i::Handle<i::Struct> struct_obj =
i::Factory::NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
i::Handle<i::ObjectTemplateInfo> obj =
......@@ -880,8 +865,8 @@ void ObjectTemplate::SetAccessor(v8::Handle<String> name,
v8::Handle<Value> data,
AccessControl settings,
PropertyAttribute attribute) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::SetAccessor()")) return;
ENTER_V8;
HandleScope scope;
EnsureConstructor(this);
i::FunctionTemplateInfo* constructor =
......@@ -902,8 +887,8 @@ void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter,
NamedPropertyDeleter remover,
NamedPropertyEnumerator enumerator,
Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::SetNamedPropertyHandler()")) return;
ENTER_V8;
HandleScope scope;
EnsureConstructor(this);
i::FunctionTemplateInfo* constructor =
......@@ -919,8 +904,8 @@ void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter,
void ObjectTemplate::MarkAsUndetectable() {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::MarkAsUndetectable()")) return;
ENTER_V8;
HandleScope scope;
EnsureConstructor(this);
i::FunctionTemplateInfo* constructor =
......@@ -935,8 +920,8 @@ void ObjectTemplate::SetAccessCheckCallbacks(
IndexedSecurityCallback indexed_callback,
Handle<Value> data,
bool turned_on_by_default) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return;
ENTER_V8;
HandleScope scope;
EnsureConstructor(this);
......@@ -964,8 +949,8 @@ void ObjectTemplate::SetIndexedPropertyHandler(
IndexedPropertyDeleter remover,
IndexedPropertyEnumerator enumerator,
Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::SetIndexedPropertyHandler()")) return;
ENTER_V8;
HandleScope scope;
EnsureConstructor(this);
i::FunctionTemplateInfo* constructor =
......@@ -982,8 +967,8 @@ void ObjectTemplate::SetIndexedPropertyHandler(
void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback,
Handle<Value> data) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::SetCallAsFunctionHandler()")) return;
ENTER_V8;
HandleScope scope;
EnsureConstructor(this);
i::FunctionTemplateInfo* constructor =
......@@ -994,7 +979,6 @@ void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback,
int ObjectTemplate::InternalFieldCount() {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::InternalFieldCount()")) {
return 0;
}
......@@ -1003,13 +987,13 @@ int ObjectTemplate::InternalFieldCount() {
void ObjectTemplate::SetInternalFieldCount(int value) {
ENTER_V8;
if (IsDeadCheck("v8::ObjectTemplate::SetInternalFieldCount()")) return;
if (!ApiCheck(i::Smi::IsValid(value),
"v8::ObjectTemplate::SetInternalFieldCount()",
"Invalid internal field count")) {
return;
}
ENTER_V8;
if (value > 0) {
// The internal field count is set by the constructor function's
// construct code, so we ensure that there is a constructor
......@@ -1040,9 +1024,9 @@ ScriptData* ScriptData::New(unsigned* data, int length) {
Local<Script> Script::Compile(v8::Handle<String> source,
v8::ScriptOrigin* origin,
v8::ScriptData* script_data) {
ENTER_V8;
ON_BAILOUT("v8::Script::Compile()", return Local<Script>());
LOG_API("Script::Compile");
ENTER_V8;
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Handle<i::Object> name_obj;
int line_offset = 0;
......@@ -1089,9 +1073,9 @@ Local<Script> Script::Compile(v8::Handle<String> source,
Local<Value> Script::Run() {
ENTER_V8;
ON_BAILOUT("v8::Script::Run()", return Local<Value>());
LOG_API("Script::Run");
ENTER_V8;
i::Object* raw_result = NULL;
{
HandleScope scope;
......@@ -1109,7 +1093,6 @@ Local<Value> Script::Run() {
Local<Value> Script::Id() {
ENTER_V8;
ON_BAILOUT("v8::Script::Id()", return Local<Value>());
LOG_API("Script::Id");
i::Object* raw_id = NULL;
......@@ -1190,8 +1173,8 @@ void v8::TryCatch::SetCaptureMessage(bool value) {
Local<String> Message::Get() const {
ENTER_V8;
ON_BAILOUT("v8::Message::Get()", return Local<String>());
ENTER_V8;
HandleScope scope;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj);
......@@ -1201,10 +1184,10 @@ Local<String> Message::Get() const {
v8::Handle<Value> Message::GetScriptResourceName() const {
ENTER_V8;
if (IsDeadCheck("v8::Message::GetScriptResourceName()")) {
return Local<String>();
}
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
......@@ -1244,8 +1227,8 @@ static i::Handle<i::Object> CallV8HeapFunction(const char* name,
int Message::GetLineNumber() const {
ENTER_V8;
ON_BAILOUT("v8::Message::GetLineNumber()", return -1);
ENTER_V8;
HandleScope scope;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
......@@ -1257,8 +1240,8 @@ int Message::GetLineNumber() const {
int Message::GetStartPosition() const {
ENTER_V8;
if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0;
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
......@@ -1267,8 +1250,8 @@ int Message::GetStartPosition() const {
int Message::GetEndPosition() const {
ENTER_V8;
if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0;
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
return static_cast<int>(GetProperty(data_obj, "endPos")->Number());
......@@ -1276,8 +1259,8 @@ int Message::GetEndPosition() const {
int Message::GetStartColumn() const {
ENTER_V8;
if (IsDeadCheck("v8::Message::GetStartColumn()")) return 0;
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE();
......@@ -1291,8 +1274,8 @@ int Message::GetStartColumn() const {
int Message::GetEndColumn() const {
ENTER_V8;
if (IsDeadCheck("v8::Message::GetEndColumn()")) return 0;
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE();
......@@ -1308,8 +1291,8 @@ int Message::GetEndColumn() const {
Local<String> Message::GetSourceLine() const {
ENTER_V8;
ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>());
ENTER_V8;
HandleScope scope;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
......@@ -1325,8 +1308,8 @@ Local<String> Message::GetSourceLine() const {
void Message::PrintCurrentStackTrace(FILE* out) {
ENTER_V8;
if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return;
ENTER_V8;
i::Top::PrintCurrentStackTrace(out);
}
......@@ -1334,84 +1317,72 @@ void Message::PrintCurrentStackTrace(FILE* out) {
// --- D a t a ---
bool Value::IsUndefined() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsUndefined()")) return false;
return Utils::OpenHandle(this)->IsUndefined();
}
bool Value::IsNull() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsNull()")) return false;
return Utils::OpenHandle(this)->IsNull();
}
bool Value::IsTrue() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsTrue()")) return false;
return Utils::OpenHandle(this)->IsTrue();
}
bool Value::IsFalse() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsFalse()")) return false;
return Utils::OpenHandle(this)->IsFalse();
}
bool Value::IsFunction() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsFunction()")) return false;
return Utils::OpenHandle(this)->IsJSFunction();
}
bool Value::IsString() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsString()")) return false;
return Utils::OpenHandle(this)->IsString();
}
bool Value::IsArray() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsArray()")) return false;
return Utils::OpenHandle(this)->IsJSArray();
}
bool Value::IsObject() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsObject()")) return false;
return Utils::OpenHandle(this)->IsJSObject();
}
bool Value::IsNumber() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsNumber()")) return false;
return Utils::OpenHandle(this)->IsNumber();
}
bool Value::IsBoolean() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsBoolean()")) return false;
return Utils::OpenHandle(this)->IsBoolean();
}
bool Value::IsExternal() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsExternal()")) return false;
return Utils::OpenHandle(this)->IsProxy();
}
bool Value::IsInt32() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsInt32()")) return false;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) return true;
......@@ -1424,7 +1395,6 @@ bool Value::IsInt32() const {
bool Value::IsDate() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IsDate()")) return false;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->HasSpecificClassOf(i::Heap::Date_symbol());
......@@ -1432,7 +1402,6 @@ bool Value::IsDate() const {
Local<String> Value::ToString() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToString()")) return Local<String>();
LOG_API("ToString");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1440,6 +1409,7 @@ Local<String> Value::ToString() const {
if (obj->IsString()) {
str = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
str = i::Execution::ToString(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<String>());
......@@ -1449,7 +1419,6 @@ Local<String> Value::ToString() const {
Local<String> Value::ToDetailString() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToDetailString()")) return Local<String>();
LOG_API("ToDetailString");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1457,6 +1426,7 @@ Local<String> Value::ToDetailString() const {
if (obj->IsString()) {
str = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
str = i::Execution::ToDetailString(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<String>());
......@@ -1466,7 +1436,6 @@ Local<String> Value::ToDetailString() const {
Local<v8::Object> Value::ToObject() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToObject()")) return Local<v8::Object>();
LOG_API("ToObject");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1474,6 +1443,7 @@ Local<v8::Object> Value::ToObject() const {
if (obj->IsJSObject()) {
val = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
val = i::Execution::ToObject(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<v8::Object>());
......@@ -1483,9 +1453,9 @@ Local<v8::Object> Value::ToObject() const {
Local<Boolean> Value::ToBoolean() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToBoolean()")) return Local<Boolean>();
LOG_API("ToBoolean");
ENTER_V8;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> val =
obj->IsBoolean() ? obj : i::Execution::ToBoolean(obj);
......@@ -1494,7 +1464,6 @@ Local<Boolean> Value::ToBoolean() const {
Local<Number> Value::ToNumber() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToNumber()")) return Local<Number>();
LOG_API("ToNumber");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1502,6 +1471,7 @@ Local<Number> Value::ToNumber() const {
if (obj->IsNumber()) {
num = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
num = i::Execution::ToNumber(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<Number>());
......@@ -1511,7 +1481,6 @@ Local<Number> Value::ToNumber() const {
Local<Integer> Value::ToInteger() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToInteger()")) return Local<Integer>();
LOG_API("ToInteger");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1519,6 +1488,7 @@ Local<Integer> Value::ToInteger() const {
if (obj->IsSmi()) {
num = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
num = i::Execution::ToInteger(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<Integer>());
......@@ -1528,7 +1498,6 @@ Local<Integer> Value::ToInteger() const {
External* External::Cast(v8::Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::External::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsProxy(),
......@@ -1539,7 +1508,6 @@ External* External::Cast(v8::Value* that) {
v8::Object* v8::Object::Cast(Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::Object::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsJSObject(),
......@@ -1550,7 +1518,6 @@ v8::Object* v8::Object::Cast(Value* that) {
v8::Function* v8::Function::Cast(Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::Function::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsJSFunction(),
......@@ -1561,7 +1528,6 @@ v8::Function* v8::Function::Cast(Value* that) {
v8::String* v8::String::Cast(v8::Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::String::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsString(),
......@@ -1572,7 +1538,6 @@ v8::String* v8::String::Cast(v8::Value* that) {
v8::Number* v8::Number::Cast(v8::Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::Number::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsNumber(),
......@@ -1583,7 +1548,6 @@ v8::Number* v8::Number::Cast(v8::Value* that) {
v8::Integer* v8::Integer::Cast(v8::Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::Integer::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsNumber(),
......@@ -1594,7 +1558,6 @@ v8::Integer* v8::Integer::Cast(v8::Value* that) {
v8::Array* v8::Array::Cast(Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::Array::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->IsJSArray(),
......@@ -1605,7 +1568,6 @@ v8::Array* v8::Array::Cast(Value* that) {
v8::Date* v8::Date::Cast(v8::Value* that) {
ENTER_V8;
if (IsDeadCheck("v8::Date::Cast()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(that);
ApiCheck(obj->HasSpecificClassOf(i::Heap::Date_symbol()),
......@@ -1616,9 +1578,9 @@ v8::Date* v8::Date::Cast(v8::Value* that) {
bool Value::BooleanValue() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::BooleanValue()")) return false;
LOG_API("BooleanValue");
ENTER_V8;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> value =
obj->IsBoolean() ? obj : i::Execution::ToBoolean(obj);
......@@ -1627,7 +1589,6 @@ bool Value::BooleanValue() const {
double Value::NumberValue() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::NumberValue()")) return i::OS::nan_value();
LOG_API("NumberValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1635,6 +1596,7 @@ double Value::NumberValue() const {
if (obj->IsNumber()) {
num = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
num = i::Execution::ToNumber(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(i::OS::nan_value());
......@@ -1644,7 +1606,6 @@ double Value::NumberValue() const {
int64_t Value::IntegerValue() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::IntegerValue()")) return 0;
LOG_API("IntegerValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1652,6 +1613,7 @@ int64_t Value::IntegerValue() const {
if (obj->IsNumber()) {
num = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
num = i::Execution::ToInteger(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(0);
......@@ -1665,7 +1627,6 @@ int64_t Value::IntegerValue() const {
Local<Int32> Value::ToInt32() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToInt32()")) return Local<Int32>();
LOG_API("ToInt32");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1673,6 +1634,7 @@ Local<Int32> Value::ToInt32() const {
if (obj->IsSmi()) {
num = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
num = i::Execution::ToInt32(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<Int32>());
......@@ -1682,7 +1644,6 @@ Local<Int32> Value::ToInt32() const {
Local<Uint32> Value::ToUint32() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToUint32()")) return Local<Uint32>();
LOG_API("ToUInt32");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1690,6 +1651,7 @@ Local<Uint32> Value::ToUint32() const {
if (obj->IsSmi()) {
num = obj;
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
num = i::Execution::ToUint32(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(Local<Uint32>());
......@@ -1699,7 +1661,6 @@ Local<Uint32> Value::ToUint32() const {
Local<Uint32> Value::ToArrayIndex() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::ToArrayIndex()")) return Local<Uint32>();
LOG_API("ToArrayIndex");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1707,6 +1668,7 @@ Local<Uint32> Value::ToArrayIndex() const {
if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
return Local<Uint32>();
}
ENTER_V8;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> string_obj =
i::Execution::ToString(obj, &has_pending_exception);
......@@ -1727,7 +1689,6 @@ Local<Uint32> Value::ToArrayIndex() const {
int32_t Value::Int32Value() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::Int32Value()")) return 0;
LOG_API("Int32Value");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1735,6 +1696,7 @@ int32_t Value::Int32Value() const {
return i::Smi::cast(*obj)->value();
} else {
LOG_API("Int32Value (slow)");
ENTER_V8;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> num =
i::Execution::ToInt32(obj, &has_pending_exception);
......@@ -1749,12 +1711,13 @@ int32_t Value::Int32Value() const {
bool Value::Equals(Handle<Value> that) const {
ENTER_V8;
if (IsDeadCheck("v8::Value::Equals()")
|| EmptyCheck("v8::Value::Equals()", this)
|| EmptyCheck("v8::Value::Equals()", that))
|| EmptyCheck("v8::Value::Equals()", that)) {
return false;
}
LOG_API("Equals");
ENTER_V8;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> other = Utils::OpenHandle(*that);
i::Object** args[1] = { other.location() };
......@@ -1767,11 +1730,11 @@ bool Value::Equals(Handle<Value> that) const {
bool Value::StrictEquals(Handle<Value> that) const {
ENTER_V8;
if (IsDeadCheck("v8::Value::StrictEquals()")
|| EmptyCheck("v8::Value::StrictEquals()", this)
|| EmptyCheck("v8::Value::StrictEquals()", that))
|| EmptyCheck("v8::Value::StrictEquals()", that)) {
return false;
}
LOG_API("StrictEquals");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> other = Utils::OpenHandle(*that);
......@@ -1798,13 +1761,13 @@ bool Value::StrictEquals(Handle<Value> that) const {
uint32_t Value::Uint32Value() const {
ENTER_V8;
if (IsDeadCheck("v8::Value::Uint32Value()")) return 0;
LOG_API("Uint32Value");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) {
return i::Smi::cast(*obj)->value();
} else {
ENTER_V8;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> num =
i::Execution::ToUint32(obj, &has_pending_exception);
......@@ -1820,8 +1783,8 @@ uint32_t Value::Uint32Value() const {
bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
v8::PropertyAttribute attribs) {
ENTER_V8;
ON_BAILOUT("v8::Object::Set()", return false);
ENTER_V8;
i::Handle<i::Object> self = Utils::OpenHandle(this);
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
......@@ -1838,8 +1801,8 @@ bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
Local<Value> v8::Object::Get(v8::Handle<Value> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::Get()", return Local<v8::Value>());
ENTER_V8;
i::Handle<i::Object> self = Utils::OpenHandle(this);
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
EXCEPTION_PREAMBLE();
......@@ -1851,8 +1814,8 @@ Local<Value> v8::Object::Get(v8::Handle<Value> key) {
Local<Value> v8::Object::GetPrototype() {
ENTER_V8;
ON_BAILOUT("v8::Object::GetPrototype()", return Local<v8::Value>());
ENTER_V8;
i::Handle<i::Object> self = Utils::OpenHandle(this);
i::Handle<i::Object> result = i::GetPrototype(self);
return Utils::ToLocal(result);
......@@ -1860,8 +1823,8 @@ Local<Value> v8::Object::GetPrototype() {
Local<Array> v8::Object::GetPropertyNames() {
ENTER_V8;
ON_BAILOUT("v8::Object::GetPropertyNames()", return Local<v8::Array>());
ENTER_V8;
v8::HandleScope scope;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::FixedArray> value = i::GetKeysInFixedArrayFor(self);
......@@ -1875,8 +1838,8 @@ Local<Array> v8::Object::GetPropertyNames() {
Local<String> v8::Object::ObjectProtoToString() {
ENTER_V8;
ON_BAILOUT("v8::Object::ObjectProtoToString()", return Local<v8::String>());
ENTER_V8;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> name(self->class_name());
......@@ -1928,8 +1891,8 @@ Local<String> v8::Object::ObjectProtoToString() {
bool v8::Object::Delete(v8::Handle<String> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::Delete()", return false);
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
......@@ -1938,7 +1901,6 @@ bool v8::Object::Delete(v8::Handle<String> key) {
bool v8::Object::Has(v8::Handle<String> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::Has()", return false);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
......@@ -1947,8 +1909,8 @@ bool v8::Object::Has(v8::Handle<String> key) {
bool v8::Object::Delete(uint32_t index) {
ENTER_V8;
ON_BAILOUT("v8::Object::DeleteProperty()", return false);
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
return i::DeleteElement(self, index)->IsTrue();
......@@ -1956,7 +1918,6 @@ bool v8::Object::Delete(uint32_t index) {
bool v8::Object::Has(uint32_t index) {
ENTER_V8;
ON_BAILOUT("v8::Object::HasProperty()", return false);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
return self->HasElement(index);
......@@ -1964,7 +1925,6 @@ bool v8::Object::Has(uint32_t index) {
bool v8::Object::HasRealNamedProperty(Handle<String> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::HasRealNamedProperty()", return false);
return Utils::OpenHandle(this)->HasRealNamedProperty(
*Utils::OpenHandle(*key));
......@@ -1972,14 +1932,12 @@ bool v8::Object::HasRealNamedProperty(Handle<String> key) {
bool v8::Object::HasRealIndexedProperty(uint32_t index) {
ENTER_V8;
ON_BAILOUT("v8::Object::HasRealIndexedProperty()", return false);
return Utils::OpenHandle(this)->HasRealElementProperty(index);
}
bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::HasRealNamedCallbackProperty()", return false);
return Utils::OpenHandle(this)->HasRealNamedCallbackProperty(
*Utils::OpenHandle(*key));
......@@ -1987,14 +1945,12 @@ bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
bool v8::Object::HasNamedLookupInterceptor() {
ENTER_V8;
ON_BAILOUT("v8::Object::HasNamedLookupInterceptor()", return false);
return Utils::OpenHandle(this)->HasNamedInterceptor();
}
bool v8::Object::HasIndexedLookupInterceptor() {
ENTER_V8;
ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false);
return Utils::OpenHandle(this)->HasIndexedInterceptor();
}
......@@ -2002,9 +1958,9 @@ bool v8::Object::HasIndexedLookupInterceptor() {
Handle<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
Handle<String> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()",
return Local<Value>());
ENTER_V8;
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
i::LookupResult lookup;
......@@ -2025,8 +1981,8 @@ Handle<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
// Because the object gets a new map, existing inline cache caching
// the old map of this object will fail.
void v8::Object::TurnOnAccessCheck() {
ENTER_V8;
ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return);
ENTER_V8;
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
i::Handle<i::Map> new_map =
......@@ -2037,8 +1993,8 @@ void v8::Object::TurnOnAccessCheck() {
Local<v8::Object> v8::Object::Clone() {
ENTER_V8;
ON_BAILOUT("v8::Object::Clone()", return Local<Object>());
ENTER_V8;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE();
i::Handle<i::JSObject> result = i::Copy(self);
......@@ -2049,8 +2005,8 @@ Local<v8::Object> v8::Object::Clone() {
int v8::Object::GetIdentityHash() {
ENTER_V8;
ON_BAILOUT("v8::Object::GetIdentityHash()", return 0);
ENTER_V8;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol();
......@@ -2071,8 +2027,8 @@ int v8::Object::GetIdentityHash() {
bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
v8::Handle<v8::Value> value) {
ENTER_V8;
ON_BAILOUT("v8::Object::SetHiddenValue()", return false);
ENTER_V8;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
......@@ -2090,8 +2046,8 @@ bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
ENTER_V8;
ON_BAILOUT("v8::Object::GetHiddenValue()", return Local<v8::Value>());
ENTER_V8;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
if (hidden_props->IsUndefined()) {
......@@ -2110,8 +2066,8 @@ v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
ENTER_V8;
ON_BAILOUT("v8::DeleteHiddenValue()", return false);
ENTER_V8;
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::JSObject> hidden_props(
i::JSObject::cast(*i::GetHiddenProperties(self, false)));
......@@ -2130,9 +2086,9 @@ Local<v8::Object> Function::NewInstance() const {
Local<v8::Object> Function::NewInstance(int argc,
v8::Handle<v8::Value> argv[]) const {
ENTER_V8;
ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>());
LOG_API("Function::NewInstance");
ENTER_V8;
HandleScope scope;
i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
......@@ -2147,9 +2103,9 @@ Local<v8::Object> Function::NewInstance(int argc,
Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc,
v8::Handle<v8::Value> argv[]) {
ENTER_V8;
ON_BAILOUT("v8::Function::Call()", return Local<v8::Value>());
LOG_API("Function::Call");
ENTER_V8;
i::Object* raw_result = NULL;
{
HandleScope scope;
......@@ -2182,23 +2138,21 @@ Handle<Value> Function::GetName() const {
int String::Length() const {
ENTER_V8;
if (IsDeadCheck("v8::String::Length()")) return 0;
return Utils::OpenHandle(this)->length();
}
int String::Utf8Length() const {
ENTER_V8;
if (IsDeadCheck("v8::String::Utf8Length()")) return 0;
return Utils::OpenHandle(this)->Utf8Length();
}
int String::WriteUtf8(char* buffer, int capacity) const {
ENTER_V8;
if (IsDeadCheck("v8::String::WriteUtf8()")) return 0;
LOG_API("String::WriteUtf8");
ENTER_V8;
i::Handle<i::String> str = Utils::OpenHandle(this);
write_input_buffer.Reset(0, *str);
int len = str->length();
......@@ -2238,9 +2192,9 @@ int String::WriteUtf8(char* buffer, int capacity) const {
int String::WriteAscii(char* buffer, int start, int length) const {
ENTER_V8;
if (IsDeadCheck("v8::String::WriteAscii()")) return 0;
LOG_API("String::WriteAscii");
ENTER_V8;
ASSERT(start >= 0 && length >= -1);
i::Handle<i::String> str = Utils::OpenHandle(this);
// Flatten the string for efficiency. This applies whether we are
......@@ -2264,9 +2218,9 @@ int String::WriteAscii(char* buffer, int start, int length) const {
int String::Write(uint16_t* buffer, int start, int length) const {
ENTER_V8;
if (IsDeadCheck("v8::String::Write()")) return 0;
LOG_API("String::Write");
ENTER_V8;
ASSERT(start >= 0 && length >= -1);
i::Handle<i::String> str = Utils::OpenHandle(this);
// Flatten the string for efficiency. This applies whether we are
......@@ -2287,7 +2241,6 @@ int String::Write(uint16_t* buffer, int start, int length) const {
bool v8::String::IsExternal() const {
ENTER_V8;
EnsureInitialized("v8::String::IsExternal()");
i::Handle<i::String> str = Utils::OpenHandle(this);
return i::StringShape(*str).IsExternalTwoByte();
......@@ -2295,7 +2248,6 @@ bool v8::String::IsExternal() const {
bool v8::String::IsExternalAscii() const {
ENTER_V8;
EnsureInitialized("v8::String::IsExternalAscii()");
i::Handle<i::String> str = Utils::OpenHandle(this);
return i::StringShape(*str).IsExternalAscii();
......@@ -2304,7 +2256,6 @@ bool v8::String::IsExternalAscii() const {
v8::String::ExternalStringResource*
v8::String::GetExternalStringResource() const {
ENTER_V8;
EnsureInitialized("v8::String::GetExternalStringResource()");
i::Handle<i::String> str = Utils::OpenHandle(this);
ASSERT(str->IsExternalTwoByteString());
......@@ -2315,7 +2266,6 @@ v8::String::GetExternalStringResource() const {
v8::String::ExternalAsciiStringResource*
v8::String::GetExternalAsciiStringResource() const {
ENTER_V8;
EnsureInitialized("v8::String::GetExternalAsciiStringResource()");
i::Handle<i::String> str = Utils::OpenHandle(this);
ASSERT(str->IsExternalAsciiString());
......@@ -2325,7 +2275,6 @@ v8::String::ExternalAsciiStringResource*
double Number::Value() const {
ENTER_V8;
if (IsDeadCheck("v8::Number::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->Number();
......@@ -2333,7 +2282,6 @@ double Number::Value() const {
bool Boolean::Value() const {
ENTER_V8;
if (IsDeadCheck("v8::Boolean::Value()")) return false;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->IsTrue();
......@@ -2341,7 +2289,6 @@ bool Boolean::Value() const {
int64_t Integer::Value() const {
ENTER_V8;
if (IsDeadCheck("v8::Integer::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) {
......@@ -2353,7 +2300,6 @@ int64_t Integer::Value() const {
int32_t Int32::Value() const {
ENTER_V8;
if (IsDeadCheck("v8::Int32::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) {
......@@ -2365,7 +2311,6 @@ int32_t Int32::Value() const {
int v8::Object::InternalFieldCount() {
ENTER_V8;
if (IsDeadCheck("v8::Object::InternalFieldCount()")) return 0;
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
return obj->GetInternalFieldCount();
......@@ -2373,7 +2318,6 @@ int v8::Object::InternalFieldCount() {
Local<Value> v8::Object::GetInternalField(int index) {
ENTER_V8;
if (IsDeadCheck("v8::Object::GetInternalField()")) return Local<Value>();
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
if (!ApiCheck(index < obj->GetInternalFieldCount(),
......@@ -2387,7 +2331,6 @@ Local<Value> v8::Object::GetInternalField(int index) {
void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
ENTER_V8;
if (IsDeadCheck("v8::Object::SetInternalField()")) return;
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
if (!ApiCheck(index < obj->GetInternalFieldCount(),
......@@ -2395,6 +2338,7 @@ void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
"Writing internal field out of bounds")) {
return;
}
ENTER_V8;
i::Handle<i::Object> val = Utils::OpenHandle(*value);
obj->SetInternalField(index, *val);
}
......@@ -2441,59 +2385,66 @@ Persistent<Context> v8::Context::New(
v8::ExtensionConfiguration* extensions,
v8::Handle<ObjectTemplate> global_template,
v8::Handle<Value> global_object) {
ENTER_V8;
EnsureInitialized("v8::Context::New()");
LOG_API("Context::New");
ON_BAILOUT("v8::Context::New()", return Persistent<Context>());
// Give the heap a chance to cleanup if we've disposed contexts.
i::Heap::CollectAllGarbageIfContextDisposed();
v8::Handle<ObjectTemplate> proxy_template = global_template;
i::Handle<i::FunctionTemplateInfo> proxy_constructor;
i::Handle<i::FunctionTemplateInfo> global_constructor;
if (!global_template.IsEmpty()) {
// Make sure that the global_template has a constructor.
global_constructor = EnsureConstructor(Utils::OpenHandle(*global_template));
// Create a fresh template for the global proxy object.
proxy_template = ObjectTemplate::New();
proxy_constructor = EnsureConstructor(Utils::OpenHandle(*proxy_template));
// Set the global template to be the prototype template of global
// proxy template.
proxy_constructor->set_prototype_template(
*Utils::OpenHandle(*global_template));
// Migrate security handlers from global_template to
// proxy_template. Temporarily removing access check information
// from the global template.
if (!global_constructor->access_check_info()->IsUndefined()) {
proxy_constructor->set_access_check_info(
global_constructor->access_check_info());
proxy_constructor->set_needs_access_check(
global_constructor->needs_access_check());
global_constructor->set_needs_access_check(false);
global_constructor->set_access_check_info(i::Heap::undefined_value());
// Enter V8 via an ENTER_V8 scope.
i::Handle<i::Context> env;
{
ENTER_V8;
// Give the heap a chance to cleanup if we've disposed contexts.
i::Heap::CollectAllGarbageIfContextDisposed();
v8::Handle<ObjectTemplate> proxy_template = global_template;
i::Handle<i::FunctionTemplateInfo> proxy_constructor;
i::Handle<i::FunctionTemplateInfo> global_constructor;
if (!global_template.IsEmpty()) {
// Make sure that the global_template has a constructor.
global_constructor =
EnsureConstructor(Utils::OpenHandle(*global_template));
// Create a fresh template for the global proxy object.
proxy_template = ObjectTemplate::New();
proxy_constructor =
EnsureConstructor(Utils::OpenHandle(*proxy_template));
// Set the global template to be the prototype template of
// global proxy template.
proxy_constructor->set_prototype_template(
*Utils::OpenHandle(*global_template));
// Migrate security handlers from global_template to
// proxy_template. Temporarily removing access check
// information from the global template.
if (!global_constructor->access_check_info()->IsUndefined()) {
proxy_constructor->set_access_check_info(
global_constructor->access_check_info());
proxy_constructor->set_needs_access_check(
global_constructor->needs_access_check());
global_constructor->set_needs_access_check(false);
global_constructor->set_access_check_info(i::Heap::undefined_value());
}
}
}
// Create the environment.
i::Handle<i::Context> env = i::Bootstrapper::CreateEnvironment(
Utils::OpenHandle(*global_object),
proxy_template,
extensions);
// Restore the access check info on the global template.
if (!global_template.IsEmpty()) {
ASSERT(!global_constructor.is_null());
ASSERT(!proxy_constructor.is_null());
global_constructor->set_access_check_info(
proxy_constructor->access_check_info());
global_constructor->set_needs_access_check(
proxy_constructor->needs_access_check());
// Create the environment.
env = i::Bootstrapper::CreateEnvironment(
Utils::OpenHandle(*global_object),
proxy_template,
extensions);
// Restore the access check info on the global template.
if (!global_template.IsEmpty()) {
ASSERT(!global_constructor.is_null());
ASSERT(!proxy_constructor.is_null());
global_constructor->set_access_check_info(
proxy_constructor->access_check_info());
global_constructor->set_needs_access_check(
proxy_constructor->needs_access_check());
}
}
// Leave V8.
if (!ApiCheck(!env.is_null(),
"v8::Context::New()",
......@@ -2504,8 +2455,8 @@ Persistent<Context> v8::Context::New(
void v8::Context::SetSecurityToken(Handle<Value> token) {
ENTER_V8;
if (IsDeadCheck("v8::Context::SetSecurityToken()")) return;
ENTER_V8;
i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
env->set_security_token(*token_handle);
......@@ -2513,15 +2464,14 @@ void v8::Context::SetSecurityToken(Handle<Value> token) {
void v8::Context::UseDefaultSecurityToken() {
ENTER_V8;
if (IsDeadCheck("v8::Context::UseDefaultSecurityToken()")) return;
ENTER_V8;
i::Handle<i::Context> env = Utils::OpenHandle(this);
env->set_security_token(env->global());
}
Handle<Value> v8::Context::GetSecurityToken() {
ENTER_V8;
if (IsDeadCheck("v8::Context::GetSecurityToken()")) return Handle<Value>();
i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Object* security_token = env->security_token();
......@@ -2542,7 +2492,6 @@ bool Context::InContext() {
v8::Local<v8::Context> Context::GetEntered() {
ENTER_V8;
if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>();
i::Handle<i::Object> last = thread_local.LastEnteredContext();
if (last.is_null()) return Local<Context>();
......@@ -2552,7 +2501,6 @@ v8::Local<v8::Context> Context::GetEntered() {
v8::Local<v8::Context> Context::GetCurrent() {
ENTER_V8;
if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>();
i::Handle<i::Context> context(i::Top::global_context());
return Utils::ToLocal(context);
......@@ -2560,7 +2508,6 @@ v8::Local<v8::Context> Context::GetCurrent() {
v8::Local<v8::Object> Context::Global() {
ENTER_V8;
if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>();
i::Object** ctx = reinterpret_cast<i::Object**>(this);
i::Handle<i::Context> context =
......@@ -2571,8 +2518,8 @@ v8::Local<v8::Object> Context::Global() {
void Context::DetachGlobal() {
ENTER_V8;
if (IsDeadCheck("v8::Context::DetachGlobal()")) return;
ENTER_V8;
i::Object** ctx = reinterpret_cast<i::Object**>(this);
i::Handle<i::Context> context =
i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
......@@ -2581,9 +2528,9 @@ void Context::DetachGlobal() {
Local<v8::Object> ObjectTemplate::NewInstance() {
ENTER_V8;
ON_BAILOUT("v8::ObjectTemplate::NewInstance()", return Local<v8::Object>());
LOG_API("ObjectTemplate::NewInstance");
ENTER_V8;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> obj =
i::Execution::InstantiateObject(Utils::OpenHandle(this),
......@@ -2594,10 +2541,10 @@ Local<v8::Object> ObjectTemplate::NewInstance() {
Local<v8::Function> FunctionTemplate::GetFunction() {
ENTER_V8;
ON_BAILOUT("v8::FunctionTemplate::GetFunction()",
return Local<v8::Function>());
LOG_API("FunctionTemplate::GetFunction");
ENTER_V8;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> obj =
i::Execution::InstantiateFunction(Utils::OpenHandle(this),
......@@ -2608,7 +2555,6 @@ Local<v8::Function> FunctionTemplate::GetFunction() {
bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) {
ENTER_V8;
ON_BAILOUT("v8::FunctionTemplate::HasInstanceOf()", return false);
i::Object* obj = *Utils::OpenHandle(*value);
return obj->IsInstanceOf(*Utils::OpenHandle(this));
......@@ -2629,10 +2575,10 @@ static const int kAlignedPointerShift = 2;
Local<Value> v8::External::Wrap(void* data) {
ENTER_V8;
STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
LOG_API("External::Wrap");
EnsureInitialized("v8::External::Wrap()");
ENTER_V8;
if ((reinterpret_cast<intptr_t>(data) & kAlignedPointerMask) == 0) {
uintptr_t data_ptr = reinterpret_cast<uintptr_t>(data);
int data_value = static_cast<int>(data_ptr >> kAlignedPointerShift);
......@@ -2645,7 +2591,6 @@ Local<Value> v8::External::Wrap(void* data) {
void* v8::External::Unwrap(v8::Handle<v8::Value> value) {
ENTER_V8;
if (IsDeadCheck("v8::External::Unwrap()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(*value);
if (obj->IsSmi()) {
......@@ -2658,16 +2603,15 @@ void* v8::External::Unwrap(v8::Handle<v8::Value> value) {
Local<External> v8::External::New(void* data) {
ENTER_V8;
STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
LOG_API("External::New");
EnsureInitialized("v8::External::New()");
ENTER_V8;
return ExternalNewImpl(data);
}
void* External::Value() const {
ENTER_V8;
if (IsDeadCheck("v8::External::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return ExternalValueImpl(obj);
......@@ -2675,7 +2619,6 @@ void* External::Value() const {
Local<String> v8::String::Empty() {
ENTER_V8;
EnsureInitialized("v8::String::Empty()");
LOG_API("String::Empty()");
return Utils::ToLocal(i::Factory::empty_symbol());
......@@ -2683,10 +2626,10 @@ Local<String> v8::String::Empty() {
Local<String> v8::String::New(const char* data, int length) {
ENTER_V8;
EnsureInitialized("v8::String::New()");
LOG_API("String::New(char)");
if (length == 0) return Empty();
ENTER_V8;
if (length == -1) length = strlen(data);
i::Handle<i::String> result =
i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length));
......@@ -2695,9 +2638,9 @@ Local<String> v8::String::New(const char* data, int length) {
Local<String> v8::String::NewUndetectable(const char* data, int length) {
ENTER_V8;
EnsureInitialized("v8::String::NewUndetectable()");
LOG_API("String::NewUndetectable(char)");
ENTER_V8;
if (length == -1) length = strlen(data);
i::Handle<i::String> result =
i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length));
......@@ -2714,10 +2657,10 @@ static int TwoByteStringLength(const uint16_t* data) {
Local<String> v8::String::New(const uint16_t* data, int length) {
ENTER_V8;
EnsureInitialized("v8::String::New()");
LOG_API("String::New(uint16_)");
if (length == 0) return Empty();
ENTER_V8;
if (length == -1) length = TwoByteStringLength(data);
i::Handle<i::String> result =
i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length));
......@@ -2726,9 +2669,9 @@ Local<String> v8::String::New(const uint16_t* data, int length) {
Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) {
ENTER_V8;
EnsureInitialized("v8::String::NewUndetectable()");
LOG_API("String::NewUndetectable(uint16_)");
ENTER_V8;
if (length == -1) length = TwoByteStringLength(data);
i::Handle<i::String> result =
i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length));
......@@ -2815,9 +2758,9 @@ static void DisposeExternalAsciiString(v8::Persistent<v8::Value> obj,
Local<String> v8::String::NewExternal(
v8::String::ExternalStringResource* resource) {
ENTER_V8;
EnsureInitialized("v8::String::NewExternal()");
LOG_API("String::NewExternal");
ENTER_V8;
const size_t total_size = resource->length() * sizeof(*resource->data());
i::Counters::total_external_string_memory.Increment(total_size);
i::Handle<i::String> result = NewExternalStringHandle(resource);
......@@ -2830,9 +2773,9 @@ Local<String> v8::String::NewExternal(
bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
ENTER_V8;
if (IsDeadCheck("v8::String::MakeExternal()")) return false;
if (this->IsExternal()) return false; // Already an external string.
ENTER_V8;
i::Handle <i::String> obj = Utils::OpenHandle(this);
bool result = obj->MakeExternal(resource);
if (result && !obj->IsSymbol()) {
......@@ -2850,9 +2793,9 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
Local<String> v8::String::NewExternal(
v8::String::ExternalAsciiStringResource* resource) {
ENTER_V8;
EnsureInitialized("v8::String::NewExternal()");
LOG_API("String::NewExternal");
ENTER_V8;
const size_t total_size = resource->length() * sizeof(*resource->data());
i::Counters::total_external_string_memory.Increment(total_size);
i::Handle<i::String> result = NewExternalAsciiStringHandle(resource);
......@@ -2866,9 +2809,9 @@ Local<String> v8::String::NewExternal(
bool v8::String::MakeExternal(
v8::String::ExternalAsciiStringResource* resource) {
ENTER_V8;
if (IsDeadCheck("v8::String::MakeExternal()")) return false;
if (this->IsExternal()) return false; // Already an external string.
ENTER_V8;
i::Handle <i::String> obj = Utils::OpenHandle(this);
bool result = obj->MakeExternal(resource);
if (result && !obj->IsSymbol()) {
......@@ -2885,9 +2828,9 @@ bool v8::String::MakeExternal(
Local<v8::Object> v8::Object::New() {
ENTER_V8;
EnsureInitialized("v8::Object::New()");
LOG_API("Object::New");
ENTER_V8;
i::Handle<i::JSObject> obj =
i::Factory::NewJSObject(i::Top::object_function());
return Utils::ToLocal(obj);
......@@ -2895,9 +2838,9 @@ Local<v8::Object> v8::Object::New() {
Local<v8::Value> v8::Date::New(double time) {
ENTER_V8;
EnsureInitialized("v8::Date::New()");
LOG_API("Date::New");
ENTER_V8;
EXCEPTION_PREAMBLE();
i::Handle<i::Object> obj =
i::Execution::NewDate(time, &has_pending_exception);
......@@ -2907,7 +2850,6 @@ Local<v8::Value> v8::Date::New(double time) {
double v8::Date::NumberValue() const {
ENTER_V8;
if (IsDeadCheck("v8::Date::NumberValue()")) return 0;
LOG_API("Date::NumberValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -2917,16 +2859,15 @@ double v8::Date::NumberValue() const {
Local<v8::Array> v8::Array::New(int length) {
ENTER_V8;
EnsureInitialized("v8::Array::New()");
LOG_API("Array::New");
ENTER_V8;
i::Handle<i::JSArray> obj = i::Factory::NewJSArray(length);
return Utils::ToLocal(obj);
}
uint32_t v8::Array::Length() const {
ENTER_V8;
if (IsDeadCheck("v8::Array::Length()")) return 0;
i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
i::Object* length = obj->length();
......@@ -2939,9 +2880,9 @@ uint32_t v8::Array::Length() const {
Local<String> v8::String::NewSymbol(const char* data, int length) {
ENTER_V8;
EnsureInitialized("v8::String::NewSymbol()");
LOG_API("String::NewSymbol(char)");
ENTER_V8;
if (length == -1) length = strlen(data);
i::Handle<i::String> result =
i::Factory::LookupSymbol(i::Vector<const char>(data, length));
......@@ -2950,19 +2891,19 @@ Local<String> v8::String::NewSymbol(const char* data, int length) {
Local<Number> v8::Number::New(double value) {
ENTER_V8;
EnsureInitialized("v8::Number::New()");
ENTER_V8;
i::Handle<i::Object> result = i::Factory::NewNumber(value);
return Utils::NumberToLocal(result);
}
Local<Integer> v8::Integer::New(int32_t value) {
ENTER_V8;
EnsureInitialized("v8::Integer::New()");
if (i::Smi::IsValid(value)) {
return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value)));
}
ENTER_V8;
i::Handle<i::Object> result = i::Factory::NewNumber(value);
return Utils::IntegerToLocal(result);
}
......@@ -2974,9 +2915,9 @@ void V8::IgnoreOutOfMemoryException() {
bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
ENTER_V8;
EnsureInitialized("v8::V8::AddMessageListener()");
ON_BAILOUT("v8::V8::AddMessageListener()", return false);
ENTER_V8;
HandleScope scope;
NeanderArray listeners(i::Factory::message_listeners());
NeanderObject obj(2);
......@@ -2990,9 +2931,9 @@ bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
void V8::RemoveMessageListeners(MessageCallback that) {
ENTER_V8;
EnsureInitialized("v8::V8::RemoveMessageListener()");
ON_BAILOUT("v8::V8::RemoveMessageListeners()", return);
ENTER_V8;
HandleScope scope;
NeanderArray listeners(i::Factory::message_listeners());
for (int i = 0; i < listeners.length(); i++) {
......@@ -3008,25 +2949,21 @@ void V8::RemoveMessageListeners(MessageCallback that) {
void V8::SetCounterFunction(CounterLookupCallback callback) {
ENTER_V8;
if (IsDeadCheck("v8::V8::SetCounterFunction()")) return;
i::StatsTable::SetCounterFunction(callback);
}
void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
ENTER_V8;
if (IsDeadCheck("v8::V8::SetCreateHistogramFunction()")) return;
i::StatsTable::SetCreateHistogramFunction(callback);
}
void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
ENTER_V8;
if (IsDeadCheck("v8::V8::SetAddHistogramSampleFunction()")) return;
i::StatsTable::SetAddHistogramSampleFunction(callback);
}
void V8::EnableSlidingStateWindow() {
ENTER_V8;
if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return;
i::Logger::EnableSlidingStateWindow();
}
......@@ -3034,14 +2971,12 @@ void V8::EnableSlidingStateWindow() {
void V8::SetFailedAccessCheckCallbackFunction(
FailedAccessCheckCallback callback) {
ENTER_V8;
if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return;
i::Top::SetFailedAccessCheckCallback(callback);
}
void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) {
ENTER_V8;
if (IsDeadCheck("v8::V8::AddObjectGroup()")) return;
STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**));
i::GlobalHandles::AddGroup(reinterpret_cast<i::Object***>(objects), length);
......@@ -3049,21 +2984,18 @@ void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) {
int V8::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) {
ENTER_V8;
if (IsDeadCheck("v8::V8::AdjustAmountOfExternalAllocatedMemory()")) return 0;
return i::Heap::AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
}
void V8::SetGlobalGCPrologueCallback(GCCallback callback) {
ENTER_V8;
if (IsDeadCheck("v8::V8::SetGlobalGCPrologueCallback()")) return;
i::Heap::SetGlobalGCPrologueCallback(callback);
}
void V8::SetGlobalGCEpilogueCallback(GCCallback callback) {
ENTER_V8;
if (IsDeadCheck("v8::V8::SetGlobalGCEpilogueCallback()")) return;
i::Heap::SetGlobalGCEpilogueCallback(callback);
}
......@@ -3083,13 +3015,13 @@ void V8::ResumeProfiler() {
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) {
ENTER_V8;
EnsureInitialized("v8::String::Utf8Value::Utf8Value()");
if (obj.IsEmpty()) {
str_ = NULL;
length_ = 0;
return;
}
ENTER_V8;
HandleScope scope;
TryCatch try_catch;
Handle<String> str = obj->ToString();
......@@ -3110,13 +3042,13 @@ String::Utf8Value::~Utf8Value() {
String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) {
ENTER_V8;
EnsureInitialized("v8::String::AsciiValue::AsciiValue()");
if (obj.IsEmpty()) {
str_ = NULL;
length_ = 0;
return;
}
ENTER_V8;
HandleScope scope;
TryCatch try_catch;
Handle<String> str = obj->ToString();
......@@ -3137,13 +3069,13 @@ String::AsciiValue::~AsciiValue() {
String::Value::Value(v8::Handle<v8::Value> obj) {
ENTER_V8;
EnsureInitialized("v8::String::Value::Value()");
if (obj.IsEmpty()) {
str_ = NULL;
length_ = 0;
return;
}
ENTER_V8;
HandleScope scope;
TryCatch try_catch;
Handle<String> str = obj->ToString();
......@@ -3163,9 +3095,9 @@ String::Value::~Value() {
}
Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) {
ENTER_V8;
LOG_API("RangeError");
ON_BAILOUT("v8::Exception::RangeError()", return Local<Value>());
ENTER_V8;
i::Object* error;
{
HandleScope scope;
......@@ -3178,9 +3110,9 @@ Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) {
}
Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) {
ENTER_V8;
LOG_API("ReferenceError");
ON_BAILOUT("v8::Exception::ReferenceError()", return Local<Value>());
ENTER_V8;
i::Object* error;
{
HandleScope scope;
......@@ -3193,9 +3125,9 @@ Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) {
}
Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) {
ENTER_V8;
LOG_API("SyntaxError");
ON_BAILOUT("v8::Exception::SyntaxError()", return Local<Value>());
ENTER_V8;
i::Object* error;
{
HandleScope scope;
......@@ -3208,9 +3140,9 @@ Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) {
}
Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) {
ENTER_V8;
LOG_API("TypeError");
ON_BAILOUT("v8::Exception::TypeError()", return Local<Value>());
ENTER_V8;
i::Object* error;
{
HandleScope scope;
......@@ -3223,9 +3155,9 @@ Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) {
}
Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) {
ENTER_V8;
LOG_API("Error");
ON_BAILOUT("v8::Exception::Error()", return Local<Value>());
ENTER_V8;
i::Object* error;
{
HandleScope scope;
......@@ -3242,9 +3174,9 @@ Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) {
bool Debug::SetDebugEventListener(DebugEventCallback that, Handle<Value> data) {
ENTER_V8;
EnsureInitialized("v8::Debug::SetDebugEventListener()");
ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false);
ENTER_V8;
HandleScope scope;
i::Handle<i::Object> proxy = i::Factory::undefined_value();
if (that != NULL) {
......@@ -3257,8 +3189,8 @@ bool Debug::SetDebugEventListener(DebugEventCallback that, Handle<Value> data) {
bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
Handle<Value> data) {
ENTER_V8;
ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false);
ENTER_V8;
i::Debugger::SetEventListener(Utils::OpenHandle(*that),
Utils::OpenHandle(*data));
return true;
......@@ -3273,8 +3205,8 @@ void Debug::DebugBreak() {
void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data,
bool message_handler_thread) {
ENTER_V8;
EnsureInitialized("v8::Debug::SetMessageHandler");
ENTER_V8;
i::Debugger::SetMessageHandler(handler, data, message_handler_thread);
}
......@@ -3287,8 +3219,8 @@ void Debug::SendCommand(const uint16_t* command, int length) {
void Debug::SetHostDispatchHandler(v8::DebugHostDispatchHandler handler,
void* data) {
ENTER_V8;
EnsureInitialized("v8::Debug::SetHostDispatchHandler");
ENTER_V8;
i::Debugger::SetHostDispatchHandler(handler, data);
}
......@@ -3301,9 +3233,9 @@ void Debug::SendHostDispatch(void* dispatch) {
Handle<Value> Debug::Call(v8::Handle<v8::Function> fun,
v8::Handle<v8::Value> data) {
ENTER_V8;
if (!i::V8::HasBeenSetup()) return Handle<Value>();
ON_BAILOUT("v8::Debug::Call()", return Handle<Value>());
ENTER_V8;
i::Handle<i::Object> result;
EXCEPTION_PREAMBLE();
if (data.IsEmpty()) {
......
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