Commit 2a25c444 authored by antonm@chromium.org's avatar antonm@chromium.org

Fix various places which do not check if SetProperty threw an exception.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6729 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5d3430a5
...@@ -670,7 +670,7 @@ static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { ...@@ -670,7 +670,7 @@ static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, void Template::Set(v8::Handle<String> name, v8::Handle<Data> value,
v8::PropertyAttribute attribute) { v8::PropertyAttribute attribute) {
if (IsDeadCheck("v8::Template::SetProperty()")) return; if (IsDeadCheck("v8::Template::Set()")) return;
ENTER_V8; ENTER_V8;
HandleScope scope; HandleScope scope;
i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list()); i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list());
......
...@@ -349,7 +349,7 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target, ...@@ -349,7 +349,7 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
prototype, prototype,
call_code, call_code,
is_ecma_native); is_ecma_native);
SetProperty(target, symbol, function, DONT_ENUM); SetLocalPropertyNoThrow(target, symbol, function, DONT_ENUM);
if (is_ecma_native) { if (is_ecma_native) {
function->shared()->set_instance_class_name(*symbol); function->shared()->set_instance_class_name(*symbol);
} }
...@@ -580,8 +580,8 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -580,8 +580,8 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
Handle<JSObject> prototype = Handle<JSObject> prototype =
Handle<JSObject>( Handle<JSObject>(
JSObject::cast(js_global_function->instance_prototype())); JSObject::cast(js_global_function->instance_prototype()));
SetProperty(prototype, Factory::constructor_symbol(), SetLocalPropertyNoThrow(
Top::object_function(), NONE); prototype, Factory::constructor_symbol(), Top::object_function(), NONE);
} else { } else {
Handle<FunctionTemplateInfo> js_global_constructor( Handle<FunctionTemplateInfo> js_global_constructor(
FunctionTemplateInfo::cast(js_global_template->constructor())); FunctionTemplateInfo::cast(js_global_template->constructor()));
...@@ -683,7 +683,8 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -683,7 +683,8 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
global_context()->set_security_token(*inner_global); global_context()->set_security_token(*inner_global);
Handle<String> object_name = Handle<String>(Heap::Object_symbol()); Handle<String> object_name = Handle<String>(Heap::Object_symbol());
SetProperty(inner_global, object_name, Top::object_function(), DONT_ENUM); SetLocalPropertyNoThrow(inner_global, object_name,
Top::object_function(), DONT_ENUM);
Handle<JSObject> global = Handle<JSObject>(global_context()->global()); Handle<JSObject> global = Handle<JSObject>(global_context()->global());
...@@ -851,7 +852,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -851,7 +852,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
cons->SetInstanceClassName(*name); cons->SetInstanceClassName(*name);
Handle<JSObject> json_object = Factory::NewJSObject(cons, TENURED); Handle<JSObject> json_object = Factory::NewJSObject(cons, TENURED);
ASSERT(json_object->IsJSObject()); ASSERT(json_object->IsJSObject());
SetProperty(global, name, json_object, DONT_ENUM); SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM);
global_context()->set_json_object(*json_object); global_context()->set_json_object(*json_object);
} }
...@@ -880,12 +881,12 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -880,12 +881,12 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
global_context()->set_arguments_boilerplate(*result); global_context()->set_arguments_boilerplate(*result);
// Note: callee must be added as the first property and // Note: callee must be added as the first property and
// length must be added as the second property. // length must be added as the second property.
SetProperty(result, Factory::callee_symbol(), SetLocalPropertyNoThrow(result, Factory::callee_symbol(),
Factory::undefined_value(), Factory::undefined_value(),
DONT_ENUM); DONT_ENUM);
SetProperty(result, Factory::length_symbol(), SetLocalPropertyNoThrow(result, Factory::length_symbol(),
Factory::undefined_value(), Factory::undefined_value(),
DONT_ENUM); DONT_ENUM);
#ifdef DEBUG #ifdef DEBUG
LookupResult lookup; LookupResult lookup;
...@@ -1085,10 +1086,8 @@ bool Genesis::InstallNatives() { ...@@ -1085,10 +1086,8 @@ bool Genesis::InstallNatives() {
static const PropertyAttributes attributes = static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
Handle<String> global_symbol = Factory::LookupAsciiSymbol("global"); Handle<String> global_symbol = Factory::LookupAsciiSymbol("global");
SetProperty(builtins, Handle<Object> global_obj(global_context()->global());
global_symbol, SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes);
Handle<Object>(global_context()->global()),
attributes);
// Setup the reference from the global object to the builtins object. // Setup the reference from the global object to the builtins object.
JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins);
...@@ -1480,17 +1479,17 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) { ...@@ -1480,17 +1479,17 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
Handle<String> natives_string = Handle<String> natives_string =
Factory::LookupAsciiSymbol(FLAG_expose_natives_as); Factory::LookupAsciiSymbol(FLAG_expose_natives_as);
SetProperty(js_global, natives_string, SetLocalPropertyNoThrow(js_global, natives_string,
Handle<JSObject>(js_global->builtins()), DONT_ENUM); Handle<JSObject>(js_global->builtins()), DONT_ENUM);
} }
Handle<Object> Error = GetProperty(js_global, "Error"); Handle<Object> Error = GetProperty(js_global, "Error");
if (Error->IsJSObject()) { if (Error->IsJSObject()) {
Handle<String> name = Factory::LookupAsciiSymbol("stackTraceLimit"); Handle<String> name = Factory::LookupAsciiSymbol("stackTraceLimit");
SetProperty(Handle<JSObject>::cast(Error), SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error),
name, name,
Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)), Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)),
NONE); NONE);
} }
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
...@@ -1507,8 +1506,8 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) { ...@@ -1507,8 +1506,8 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
Handle<String> debug_string = Handle<String> debug_string =
Factory::LookupAsciiSymbol(FLAG_expose_debug_as); Factory::LookupAsciiSymbol(FLAG_expose_debug_as);
SetProperty(js_global, debug_string, Handle<Object> global_proxy(Debug::debug_context()->global_proxy());
Handle<Object>(Debug::debug_context()->global_proxy()), DONT_ENUM); SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM);
} }
#endif #endif
} }
...@@ -1679,7 +1678,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from, ...@@ -1679,7 +1678,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
Handle<String> key = Handle<String>(descs->GetKey(i)); Handle<String> key = Handle<String>(descs->GetKey(i));
int index = descs->GetFieldIndex(i); int index = descs->GetFieldIndex(i);
Handle<Object> value = Handle<Object>(from->FastPropertyAt(index)); Handle<Object> value = Handle<Object>(from->FastPropertyAt(index));
SetProperty(to, key, value, details.attributes()); SetLocalPropertyNoThrow(to, key, value, details.attributes());
break; break;
} }
case CONSTANT_FUNCTION: { case CONSTANT_FUNCTION: {
...@@ -1687,7 +1686,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from, ...@@ -1687,7 +1686,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
Handle<String> key = Handle<String>(descs->GetKey(i)); Handle<String> key = Handle<String>(descs->GetKey(i));
Handle<JSFunction> fun = Handle<JSFunction> fun =
Handle<JSFunction>(descs->GetConstantFunction(i)); Handle<JSFunction>(descs->GetConstantFunction(i));
SetProperty(to, key, fun, details.attributes()); SetLocalPropertyNoThrow(to, key, fun, details.attributes());
break; break;
} }
case CALLBACKS: { case CALLBACKS: {
...@@ -1737,7 +1736,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from, ...@@ -1737,7 +1736,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value()); value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value());
} }
PropertyDetails details = properties->DetailsAt(i); PropertyDetails details = properties->DetailsAt(i);
SetProperty(to, key, value, details.attributes()); SetLocalPropertyNoThrow(to, key, value, details.attributes());
} }
} }
} }
......
...@@ -835,7 +835,9 @@ bool Debug::Load() { ...@@ -835,7 +835,9 @@ bool Debug::Load() {
// Expose the builtins object in the debugger context. // Expose the builtins object in the debugger context.
Handle<String> key = Factory::LookupAsciiSymbol("builtins"); Handle<String> key = Factory::LookupAsciiSymbol("builtins");
Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); Handle<GlobalObject> global = Handle<GlobalObject>(context->global());
SetProperty(global, key, Handle<Object>(global->builtins()), NONE); RETURN_IF_EMPTY_HANDLE_VALUE(
SetProperty(global, key, Handle<Object>(global->builtins()), NONE),
false);
// Compile the JavaScript for the debugger in the debugger context. // Compile the JavaScript for the debugger in the debugger context.
Debugger::set_compiling_natives(true); Debugger::set_compiling_natives(true);
......
...@@ -585,7 +585,9 @@ Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, ...@@ -585,7 +585,9 @@ Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
// Set function.prototype and give the prototype a constructor // Set function.prototype and give the prototype a constructor
// property that refers to the function. // property that refers to the function.
SetPrototypeProperty(function, prototype); SetPrototypeProperty(function, prototype);
SetProperty(prototype, Factory::constructor_symbol(), function, DONT_ENUM); // Currently safe because it is only invoked from Genesis.
SetLocalPropertyNoThrow(
prototype, Factory::constructor_symbol(), function, DONT_ENUM);
return function; return function;
} }
......
...@@ -290,6 +290,17 @@ Handle<Object> SetLocalPropertyIgnoreAttributes( ...@@ -290,6 +290,17 @@ Handle<Object> SetLocalPropertyIgnoreAttributes(
} }
void SetLocalPropertyNoThrow(Handle<JSObject> object,
Handle<String> key,
Handle<Object> value,
PropertyAttributes attributes) {
ASSERT(!Top::has_pending_exception());
CHECK(!SetLocalPropertyIgnoreAttributes(
object, key, value, attributes).is_null());
CHECK(!Top::has_pending_exception());
}
Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
Handle<String> key, Handle<String> key,
Handle<Object> value, Handle<Object> value,
......
...@@ -223,6 +223,13 @@ Handle<Object> SetLocalPropertyIgnoreAttributes( ...@@ -223,6 +223,13 @@ Handle<Object> SetLocalPropertyIgnoreAttributes(
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes); PropertyAttributes attributes);
// Used to set local properties on the object we totally control
// and which therefore has no accessors and alikes.
void SetLocalPropertyNoThrow(Handle<JSObject> object,
Handle<String> key,
Handle<Object> value,
PropertyAttributes attributes = NONE);
Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
Handle<String> key, Handle<String> key,
Handle<Object> value, Handle<Object> value,
......
This diff is collapsed.
...@@ -374,18 +374,6 @@ Handle<String> Top::StackTraceString() { ...@@ -374,18 +374,6 @@ Handle<String> Top::StackTraceString() {
} }
static void SetLocalProperty(Handle<JSObject> object,
Handle<String> key,
Handle<Object> value) {
// We set properties on freshly allocated JS object, nothing
// should fail except for OOM which is handled by
// SetLocalPropertyIgnoreAttributes.
ASSERT(!Top::has_pending_exception());
CHECK(!SetLocalPropertyIgnoreAttributes(object, key, value, NONE).is_null());
CHECK(!Top::has_pending_exception());
}
Handle<JSArray> Top::CaptureCurrentStackTrace( Handle<JSArray> Top::CaptureCurrentStackTrace(
int frame_limit, StackTrace::StackTraceOptions options) { int frame_limit, StackTrace::StackTraceOptions options) {
// Ensure no negative values. // Ensure no negative values.
...@@ -433,16 +421,16 @@ Handle<JSArray> Top::CaptureCurrentStackTrace( ...@@ -433,16 +421,16 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
// tag. // tag.
column_offset += script->column_offset()->value(); column_offset += script->column_offset()->value();
} }
SetLocalProperty(stackFrame, column_key, SetLocalPropertyNoThrow(stackFrame, column_key,
Handle<Smi>(Smi::FromInt(column_offset + 1))); Handle<Smi>(Smi::FromInt(column_offset + 1)));
} }
SetLocalProperty(stackFrame, line_key, SetLocalPropertyNoThrow(stackFrame, line_key,
Handle<Smi>(Smi::FromInt(line_number + 1))); Handle<Smi>(Smi::FromInt(line_number + 1)));
} }
if (options & StackTrace::kScriptName) { if (options & StackTrace::kScriptName) {
Handle<Object> script_name(script->name()); Handle<Object> script_name(script->name());
SetLocalProperty(stackFrame, script_key, script_name); SetLocalPropertyNoThrow(stackFrame, script_key, script_name);
} }
if (options & StackTrace::kScriptNameOrSourceURL) { if (options & StackTrace::kScriptNameOrSourceURL) {
...@@ -458,7 +446,8 @@ Handle<JSArray> Top::CaptureCurrentStackTrace( ...@@ -458,7 +446,8 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
if (caught_exception) { if (caught_exception) {
result = Factory::undefined_value(); result = Factory::undefined_value();
} }
SetLocalProperty(stackFrame, script_name_or_source_url_key, result); SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key,
result);
} }
if (options & StackTrace::kFunctionName) { if (options & StackTrace::kFunctionName) {
...@@ -466,20 +455,20 @@ Handle<JSArray> Top::CaptureCurrentStackTrace( ...@@ -466,20 +455,20 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
if (fun_name->ToBoolean()->IsFalse()) { if (fun_name->ToBoolean()->IsFalse()) {
fun_name = Handle<Object>(fun->shared()->inferred_name()); fun_name = Handle<Object>(fun->shared()->inferred_name());
} }
SetLocalProperty(stackFrame, function_key, fun_name); SetLocalPropertyNoThrow(stackFrame, function_key, fun_name);
} }
if (options & StackTrace::kIsEval) { if (options & StackTrace::kIsEval) {
int type = Smi::cast(script->compilation_type())->value(); int type = Smi::cast(script->compilation_type())->value();
Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
Factory::true_value() : Factory::false_value(); Factory::true_value() : Factory::false_value();
SetLocalProperty(stackFrame, eval_key, is_eval); SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval);
} }
if (options & StackTrace::kIsConstructor) { if (options & StackTrace::kIsConstructor) {
Handle<Object> is_constructor = (frames[i].is_constructor()) ? Handle<Object> is_constructor = (frames[i].is_constructor()) ?
Factory::true_value() : Factory::false_value(); Factory::true_value() : Factory::false_value();
SetLocalProperty(stackFrame, constructor_key, is_constructor); SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor);
} }
FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame); FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame);
......
...@@ -41,6 +41,15 @@ class Simulator; ...@@ -41,6 +41,15 @@ class Simulator;
#define RETURN_IF_SCHEDULED_EXCEPTION() \ #define RETURN_IF_SCHEDULED_EXCEPTION() \
if (Top::has_scheduled_exception()) return Top::PromoteScheduledException() if (Top::has_scheduled_exception()) return Top::PromoteScheduledException()
#define RETURN_IF_EMPTY_HANDLE_VALUE(call, value) \
if (call.is_null()) { \
ASSERT(Top::has_pending_exception()); \
return value; \
}
#define RETURN_IF_EMPTY_HANDLE(call) \
RETURN_IF_EMPTY_HANDLE_VALUE(call, Failure::Exception())
// Top has static variables used for JavaScript execution. // Top has static variables used for JavaScript execution.
class SaveContext; // Forward declaration. class SaveContext; // Forward declaration.
......
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