Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Unified Diff: src/runtime.cc

Issue 3970005: Make Failure inherit from MaybeObject instead of Object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.h ('k') | src/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 5696)
+++ src/runtime.cc (working copy)
@@ -99,12 +99,14 @@
static StaticResource<StringInputBuffer> runtime_string_input_buffer;
-MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
+MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(JSObject* boilerplate) {
StackLimitCheck check;
if (check.HasOverflowed()) return Top::StackOverflow();
- Object* result = Heap::CopyJSObject(boilerplate);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Heap::CopyJSObject(boilerplate);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
JSObject* copy = JSObject::cast(result);
// Deep copy local properties.
@@ -114,8 +116,9 @@
Object* value = properties->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
properties->set(i, result);
}
}
@@ -124,14 +127,17 @@
Object* value = copy->InObjectPropertyAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
copy->InObjectPropertyAtPut(i, result);
}
}
} else {
- result = Heap::AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result =
+ Heap::AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
FixedArray* names = FixedArray::cast(result);
copy->GetLocalPropertyNames(names, 0);
for (int i = 0; i < names->length(); i++) {
@@ -143,14 +149,17 @@
// In particular, don't try to copy the length attribute of
// an array.
if (attributes != NONE) continue;
- Object* value = copy->GetProperty(key_string, &attributes);
- ASSERT(!value->IsFailure());
+ Object* value =
+ copy->GetProperty(key_string, &attributes)->ToObjectUnchecked();
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
- result = copy->SetProperty(key_string, result, NONE);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
+ { MaybeObject* maybe_result =
+ copy->SetProperty(key_string, result, NONE);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
}
}
}
@@ -173,8 +182,9 @@
Object* value = elements->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
elements->set(i, result);
}
}
@@ -190,8 +200,9 @@
Object* value = element_dictionary->ValueAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
element_dictionary->ValueAtPut(i, result);
}
}
@@ -206,13 +217,13 @@
}
-static Object* Runtime_CloneLiteralBoilerplate(Arguments args) {
+static MaybeObject* Runtime_CloneLiteralBoilerplate(Arguments args) {
CONVERT_CHECKED(JSObject, boilerplate, args[0]);
return DeepCopyBoilerplate(boilerplate);
}
-static Object* Runtime_CloneShallowLiteralBoilerplate(Arguments args) {
+static MaybeObject* Runtime_CloneShallowLiteralBoilerplate(Arguments args) {
CONVERT_CHECKED(JSObject, boilerplate, args[0]);
return Heap::CopyJSObject(boilerplate);
}
@@ -403,7 +414,7 @@
}
-static Object* Runtime_CreateArrayLiteralBoilerplate(Arguments args) {
+static MaybeObject* Runtime_CreateArrayLiteralBoilerplate(Arguments args) {
// Takes a FixedArray of elements containing the literal elements of
// the array literal and produces JSArray with those elements.
// Additionally takes the literals array of the surrounding function
@@ -424,7 +435,7 @@
}
-static Object* Runtime_CreateObjectLiteral(Arguments args) {
+static MaybeObject* Runtime_CreateObjectLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -447,7 +458,7 @@
}
-static Object* Runtime_CreateObjectLiteralShallow(Arguments args) {
+static MaybeObject* Runtime_CreateObjectLiteralShallow(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -470,7 +481,7 @@
}
-static Object* Runtime_CreateArrayLiteral(Arguments args) {
+static MaybeObject* Runtime_CreateArrayLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -489,7 +500,7 @@
}
-static Object* Runtime_CreateArrayLiteralShallow(Arguments args) {
+static MaybeObject* Runtime_CreateArrayLiteralShallow(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -512,24 +523,28 @@
}
-static Object* Runtime_CreateCatchExtensionObject(Arguments args) {
+static MaybeObject* Runtime_CreateCatchExtensionObject(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, key, args[0]);
Object* value = args[1];
// Create a catch context extension object.
JSFunction* constructor =
Top::context()->global_context()->context_extension_function();
- Object* object = Heap::AllocateJSObject(constructor);
- if (object->IsFailure()) return object;
+ Object* object;
+ { MaybeObject* maybe_object = Heap::AllocateJSObject(constructor);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
// Assign the exception value to the catch variable and make sure
// that the catch variable is DontDelete.
- value = JSObject::cast(object)->SetProperty(key, value, DONT_DELETE);
- if (value->IsFailure()) return value;
+ { MaybeObject* maybe_value =
+ JSObject::cast(object)->SetProperty(key, value, DONT_DELETE);
+ if (!maybe_value->ToObject(&value)) return maybe_value;
+ }
return object;
}
-static Object* Runtime_ClassOf(Arguments args) {
+static MaybeObject* Runtime_ClassOf(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Object* obj = args[0];
@@ -538,7 +553,7 @@
}
-static Object* Runtime_IsInPrototypeChain(Arguments args) {
+static MaybeObject* Runtime_IsInPrototypeChain(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
// See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
@@ -554,7 +569,7 @@
// Inserts an object as the hidden prototype of another object.
-static Object* Runtime_SetHiddenPrototype(Arguments args) {
+static MaybeObject* Runtime_SetHiddenPrototype(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSObject, jsobject, args[0]);
@@ -568,12 +583,19 @@
RUNTIME_ASSERT(!proto->map()->is_hidden_prototype());
// Allocate up front before we start altering state in case we get a GC.
- Object* map_or_failure = proto->map()->CopyDropTransitions();
- if (map_or_failure->IsFailure()) return map_or_failure;
+ Object* map_or_failure;
+ { MaybeObject* maybe_map_or_failure = proto->map()->CopyDropTransitions();
+ if (!maybe_map_or_failure->ToObject(&map_or_failure)) {
+ return maybe_map_or_failure;
+ }
+ }
Map* new_proto_map = Map::cast(map_or_failure);
- map_or_failure = jsobject->map()->CopyDropTransitions();
- if (map_or_failure->IsFailure()) return map_or_failure;
+ { MaybeObject* maybe_map_or_failure = jsobject->map()->CopyDropTransitions();
+ if (!maybe_map_or_failure->ToObject(&map_or_failure)) {
+ return maybe_map_or_failure;
+ }
+ }
Map* new_map = Map::cast(map_or_failure);
// Set proto's prototype to be the old prototype of the object.
@@ -589,7 +611,7 @@
}
-static Object* Runtime_IsConstructCall(Arguments args) {
+static MaybeObject* Runtime_IsConstructCall(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
JavaScriptFrameIterator it;
@@ -632,7 +654,7 @@
// [false, value, Writeable, Enumerable, Configurable]
// if args[1] is an accessor on args[0]
// [true, GetFunction, SetFunction, Enumerable, Configurable]
-static Object* Runtime_GetOwnProperty(Arguments args) {
+static MaybeObject* Runtime_GetOwnProperty(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
Handle<FixedArray> elms = Factory::NewFixedArray(DESCRIPTOR_SIZE);
@@ -719,9 +741,11 @@
if (structure->IsProxy() || structure->IsAccessorInfo()) {
// Property that is internally implemented as a callback or
// an API defined callback.
- Object* value = obj->GetPropertyWithCallback(
- *obj, structure, *name, result.holder());
- if (value->IsFailure()) return value;
+ Object* value;
+ { MaybeObject* maybe_value = obj->GetPropertyWithCallback(
+ *obj, structure, *name, result.holder());
+ if (!maybe_value->ToObject(&value)) return maybe_value;
+ }
elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
elms->set(VALUE_INDEX, value);
elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly()));
@@ -745,13 +769,13 @@
}
-static Object* Runtime_PreventExtensions(Arguments args) {
+static MaybeObject* Runtime_PreventExtensions(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, obj, args[0]);
return obj->PreventExtensions();
}
-static Object* Runtime_IsExtensible(Arguments args) {
+static MaybeObject* Runtime_IsExtensible(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, obj, args[0]);
return obj->map()->is_extensible() ? Heap::true_value()
@@ -759,7 +783,7 @@
}
-static Object* Runtime_RegExpCompile(Arguments args) {
+static MaybeObject* Runtime_RegExpCompile(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSRegExp, re, 0);
@@ -771,7 +795,7 @@
}
-static Object* Runtime_CreateApiFunction(Arguments args) {
+static MaybeObject* Runtime_CreateApiFunction(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0);
@@ -779,7 +803,7 @@
}
-static Object* Runtime_IsTemplate(Arguments args) {
+static MaybeObject* Runtime_IsTemplate(Arguments args) {
ASSERT(args.length() == 1);
Object* arg = args[0];
bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
@@ -787,7 +811,7 @@
}
-static Object* Runtime_GetTemplateField(Arguments args) {
+static MaybeObject* Runtime_GetTemplateField(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(HeapObject, templ, args[0]);
CONVERT_CHECKED(Smi, field, args[1]);
@@ -806,15 +830,17 @@
}
-static Object* Runtime_DisableAccessChecks(Arguments args) {
+static MaybeObject* Runtime_DisableAccessChecks(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(HeapObject, object, args[0]);
Map* old_map = object->map();
bool needs_access_checks = old_map->is_access_check_needed();
if (needs_access_checks) {
// Copy map so it won't interfere constructor's initial map.
- Object* new_map = old_map->CopyDropTransitions();
- if (new_map->IsFailure()) return new_map;
+ Object* new_map;
+ { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
+ if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
+ }
Map::cast(new_map)->set_is_access_check_needed(false);
object->set_map(Map::cast(new_map));
@@ -823,14 +849,16 @@
}
-static Object* Runtime_EnableAccessChecks(Arguments args) {
+static MaybeObject* Runtime_EnableAccessChecks(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(HeapObject, object, args[0]);
Map* old_map = object->map();
if (!old_map->is_access_check_needed()) {
// Copy map so it won't interfere constructor's initial map.
- Object* new_map = old_map->CopyDropTransitions();
- if (new_map->IsFailure()) return new_map;
+ Object* new_map;
+ { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
+ if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
+ }
Map::cast(new_map)->set_is_access_check_needed(true);
object->set_map(Map::cast(new_map));
@@ -839,7 +867,7 @@
}
-static Object* ThrowRedeclarationError(const char* type, Handle<String> name) {
+static Failure* ThrowRedeclarationError(const char* type, Handle<String> name) {
HandleScope scope;
Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type));
Handle<Object> args[2] = { type_handle, name };
@@ -849,7 +877,7 @@
}
-static Object* Runtime_DeclareGlobals(Arguments args) {
+static MaybeObject* Runtime_DeclareGlobals(Arguments args) {
HandleScope scope;
Handle<GlobalObject> global = Handle<GlobalObject>(Top::context()->global());
@@ -961,7 +989,7 @@
}
-static Object* Runtime_DeclareContextSlot(Arguments args) {
+static MaybeObject* Runtime_DeclareContextSlot(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
@@ -1046,7 +1074,7 @@
}
-static Object* Runtime_InitializeVarGlobal(Arguments args) {
+static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) {
NoHandleAllocation nha;
// Determine if we need to assign to the variable if it already
@@ -1139,7 +1167,7 @@
}
-static Object* Runtime_InitializeConstGlobal(Arguments args) {
+static MaybeObject* Runtime_InitializeConstGlobal(Arguments args) {
// All constants are declared with an initial value. The name
// of the constant is the first argument and the initial value
// is the second.
@@ -1187,12 +1215,13 @@
// Restore global object from context (in case of GC) and continue
// with setting the value because the property is either absent or
// read-only. We also have to do redo the lookup.
- global = Top::context()->global();
+ HandleScope handle_scope;
+ Handle<GlobalObject>global(Top::context()->global());
// BUG 1213579: Handle the case where we have to set a read-only
// property through an interceptor and only do it if it's
// uninitialized, e.g. the hole. Nirk...
- global->SetProperty(*name, *value, attributes);
+ SetProperty(global, name, value, attributes);
return *value;
}
@@ -1221,7 +1250,7 @@
}
-static Object* Runtime_InitializeConstContextSlot(Arguments args) {
+static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
@@ -1326,7 +1355,7 @@
}
-static Object* Runtime_OptimizeObjectForAddingMultipleProperties(
+static MaybeObject* Runtime_OptimizeObjectForAddingMultipleProperties(
Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -1339,7 +1368,7 @@
}
-static Object* Runtime_RegExpExec(Arguments args) {
+static MaybeObject* Runtime_RegExpExec(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
@@ -1361,19 +1390,23 @@
}
-static Object* Runtime_RegExpConstructResult(Arguments args) {
+static MaybeObject* Runtime_RegExpConstructResult(Arguments args) {
ASSERT(args.length() == 3);
CONVERT_SMI_CHECKED(elements_count, args[0]);
if (elements_count > JSArray::kMaxFastElementsLength) {
return Top::ThrowIllegalOperation();
}
- Object* new_object = Heap::AllocateFixedArrayWithHoles(elements_count);
- if (new_object->IsFailure()) return new_object;
+ Object* new_object;
+ { MaybeObject* maybe_new_object =
+ Heap::AllocateFixedArrayWithHoles(elements_count);
+ if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
+ }
FixedArray* elements = FixedArray::cast(new_object);
- new_object = Heap::AllocateRaw(JSRegExpResult::kSize,
- NEW_SPACE,
- OLD_POINTER_SPACE);
- if (new_object->IsFailure()) return new_object;
+ { MaybeObject* maybe_new_object = Heap::AllocateRaw(JSRegExpResult::kSize,
+ NEW_SPACE,
+ OLD_POINTER_SPACE);
+ if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
+ }
{
AssertNoAllocation no_gc;
HandleScope scope;
@@ -1391,7 +1424,7 @@
}
-static Object* Runtime_RegExpCloneResult(Arguments args) {
+static MaybeObject* Runtime_RegExpCloneResult(Arguments args) {
ASSERT(args.length() == 1);
Map* regexp_result_map;
{
@@ -1414,10 +1447,13 @@
ASSERT(result->properties() == Heap::empty_fixed_array());
ASSERT_EQ(2, regexp_result_map->inobject_properties());
- Object* new_array_alloc = Heap::AllocateRaw(JSRegExpResult::kSize,
- NEW_SPACE,
- OLD_POINTER_SPACE);
- if (new_array_alloc->IsFailure()) return new_array_alloc;
+ Object* new_array_alloc;
+ { MaybeObject* maybe_new_array_alloc =
+ Heap::AllocateRaw(JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE);
+ if (!maybe_new_array_alloc->ToObject(&new_array_alloc)) {
+ return maybe_new_array_alloc;
+ }
+ }
// Set HeapObject map to JSRegExpResult map.
reinterpret_cast<HeapObject*>(new_array_alloc)->set_map(regexp_result_map);
@@ -1448,7 +1484,7 @@
}
-static Object* Runtime_RegExpInitializeObject(Arguments args) {
+static MaybeObject* Runtime_RegExpInitializeObject(Arguments args) {
AssertNoAllocation no_alloc;
ASSERT(args.length() == 5);
CONVERT_CHECKED(JSRegExp, regexp, args[0]);
@@ -1480,31 +1516,42 @@
return regexp;
}
- // Map has changed, so use generic, but slower, method.
+ // Map has changed, so use generic, but slower, method. Since these
+ // properties were all added as DONT_DELETE they must be present and
+ // normal so no failures can be expected.
PropertyAttributes final =
static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
PropertyAttributes writable =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::source_symbol(),
- source,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::global_symbol(),
- global,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::ignore_case_symbol(),
- ignoreCase,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::multiline_symbol(),
- multiline,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::last_index_symbol(),
- Smi::FromInt(0),
- writable);
+ MaybeObject* result;
+ result = regexp->IgnoreAttributesAndSetLocalProperty(Heap::source_symbol(),
+ source,
+ final);
+ ASSERT(!result->IsFailure());
+ result = regexp->IgnoreAttributesAndSetLocalProperty(Heap::global_symbol(),
+ global,
+ final);
+ ASSERT(!result->IsFailure());
+ result =
+ regexp->IgnoreAttributesAndSetLocalProperty(Heap::ignore_case_symbol(),
+ ignoreCase,
+ final);
+ ASSERT(!result->IsFailure());
+ result = regexp->IgnoreAttributesAndSetLocalProperty(Heap::multiline_symbol(),
+ multiline,
+ final);
+ ASSERT(!result->IsFailure());
+ result =
+ regexp->IgnoreAttributesAndSetLocalProperty(Heap::last_index_symbol(),
+ Smi::FromInt(0),
+ writable);
+ ASSERT(!result->IsFailure());
+ USE(result);
return regexp;
}
-static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) {
+static MaybeObject* Runtime_FinishArrayPrototypeSetup(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSArray, prototype, 0);
@@ -1531,7 +1578,7 @@
}
-static Object* Runtime_SpecialArrayFunctions(Arguments args) {
+static MaybeObject* Runtime_SpecialArrayFunctions(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, holder, 0);
@@ -1548,14 +1595,14 @@
}
-static Object* Runtime_GetGlobalReceiver(Arguments args) {
+static MaybeObject* Runtime_GetGlobalReceiver(Arguments args) {
// Returns a real global receiver, not one of builtins object.
Context* global_context = Top::context()->global()->global_context();
return global_context->global()->global_receiver();
}
-static Object* Runtime_MaterializeRegExpLiteral(Arguments args) {
+static MaybeObject* Runtime_MaterializeRegExpLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -1585,7 +1632,7 @@
}
-static Object* Runtime_FunctionGetName(Arguments args) {
+static MaybeObject* Runtime_FunctionGetName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1594,7 +1641,7 @@
}
-static Object* Runtime_FunctionSetName(Arguments args) {
+static MaybeObject* Runtime_FunctionSetName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1605,19 +1652,21 @@
}
-static Object* Runtime_FunctionRemovePrototype(Arguments args) {
+static MaybeObject* Runtime_FunctionRemovePrototype(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, f, args[0]);
- Object* obj = f->RemovePrototype();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = f->RemovePrototype();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return Heap::undefined_value();
}
-static Object* Runtime_FunctionGetScript(Arguments args) {
+static MaybeObject* Runtime_FunctionGetScript(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -1629,7 +1678,7 @@
}
-static Object* Runtime_FunctionGetSourceCode(Arguments args) {
+static MaybeObject* Runtime_FunctionGetSourceCode(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1638,7 +1687,7 @@
}
-static Object* Runtime_FunctionGetScriptSourcePosition(Arguments args) {
+static MaybeObject* Runtime_FunctionGetScriptSourcePosition(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1648,7 +1697,7 @@
}
-static Object* Runtime_FunctionGetPositionForOffset(Arguments args) {
+static MaybeObject* Runtime_FunctionGetPositionForOffset(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSFunction, fun, args[0]);
@@ -1663,7 +1712,7 @@
-static Object* Runtime_FunctionSetInstanceClassName(Arguments args) {
+static MaybeObject* Runtime_FunctionSetInstanceClassName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1674,7 +1723,7 @@
}
-static Object* Runtime_FunctionSetLength(Arguments args) {
+static MaybeObject* Runtime_FunctionSetLength(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1685,19 +1734,22 @@
}
-static Object* Runtime_FunctionSetPrototype(Arguments args) {
+static MaybeObject* Runtime_FunctionSetPrototype(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSFunction, fun, args[0]);
ASSERT(fun->should_have_prototype());
- Object* obj = Accessors::FunctionSetPrototype(fun, args[1], NULL);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj =
+ Accessors::FunctionSetPrototype(fun, args[1], NULL);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return args[0]; // return TOS
}
-static Object* Runtime_FunctionIsAPIFunction(Arguments args) {
+static MaybeObject* Runtime_FunctionIsAPIFunction(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1706,7 +1758,7 @@
: Heap::false_value();
}
-static Object* Runtime_FunctionIsBuiltin(Arguments args) {
+static MaybeObject* Runtime_FunctionIsBuiltin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1715,7 +1767,7 @@
}
-static Object* Runtime_SetCode(Arguments args) {
+static MaybeObject* Runtime_SetCode(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -1772,7 +1824,7 @@
}
-static Object* Runtime_SetExpectedNumberOfProperties(Arguments args) {
+static MaybeObject* Runtime_SetExpectedNumberOfProperties(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -1783,7 +1835,7 @@
}
-static Object* CharFromCode(Object* char_code) {
+MUST_USE_RESULT static MaybeObject* CharFromCode(Object* char_code) {
uint32_t code;
if (char_code->ToArrayIndex(&code)) {
if (code <= 0xffff) {
@@ -1794,7 +1846,7 @@
}
-static Object* Runtime_StringCharCodeAt(Arguments args) {
+static MaybeObject* Runtime_StringCharCodeAt(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1816,8 +1868,10 @@
// Flatten the string. If someone wants to get a char at an index
// in a cons string, it is likely that more indices will be
// accessed.
- Object* flat = subject->TryFlatten();
- if (flat->IsFailure()) return flat;
+ Object* flat;
+ { MaybeObject* maybe_flat = subject->TryFlatten();
+ if (!maybe_flat->ToObject(&flat)) return maybe_flat;
+ }
subject = String::cast(flat);
if (i >= static_cast<uint32_t>(subject->length())) {
@@ -1828,7 +1882,7 @@
}
-static Object* Runtime_CharFromCode(Arguments args) {
+static MaybeObject* Runtime_CharFromCode(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
return CharFromCode(args[0]);
@@ -2317,10 +2371,11 @@
-static Object* StringReplaceRegExpWithString(String* subject,
- JSRegExp* regexp,
- String* replacement,
- JSArray* last_match_info) {
+MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString(
+ String* subject,
+ JSRegExp* regexp,
+ String* replacement,
+ JSArray* last_match_info) {
ASSERT(subject->IsFlat());
ASSERT(replacement->IsFlat());
@@ -2425,9 +2480,10 @@
template <typename ResultSeqString>
-static Object* StringReplaceRegExpWithEmptyString(String* subject,
- JSRegExp* regexp,
- JSArray* last_match_info) {
+MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
+ String* subject,
+ JSRegExp* regexp,
+ JSArray* last_match_info) {
ASSERT(subject->IsFlat());
HandleScope handles;
@@ -2552,23 +2608,27 @@
}
-static Object* Runtime_StringReplaceRegExpWithString(Arguments args) {
+static MaybeObject* Runtime_StringReplaceRegExpWithString(Arguments args) {
ASSERT(args.length() == 4);
CONVERT_CHECKED(String, subject, args[0]);
if (!subject->IsFlat()) {
- Object* flat_subject = subject->TryFlatten();
- if (flat_subject->IsFailure()) {
- return flat_subject;
+ Object* flat_subject;
+ { MaybeObject* maybe_flat_subject = subject->TryFlatten();
+ if (!maybe_flat_subject->ToObject(&flat_subject)) {
+ return maybe_flat_subject;
+ }
}
subject = String::cast(flat_subject);
}
CONVERT_CHECKED(String, replacement, args[2]);
if (!replacement->IsFlat()) {
- Object* flat_replacement = replacement->TryFlatten();
- if (flat_replacement->IsFailure()) {
- return flat_replacement;
+ Object* flat_replacement;
+ { MaybeObject* maybe_flat_replacement = replacement->TryFlatten();
+ if (!maybe_flat_replacement->ToObject(&flat_replacement)) {
+ return maybe_flat_replacement;
+ }
}
replacement = String::cast(flat_replacement);
}
@@ -2636,7 +2696,7 @@
}
-static Object* Runtime_StringIndexOf(Arguments args) {
+static MaybeObject* Runtime_StringIndexOf(Arguments args) {
HandleScope scope; // create a new handle scope
ASSERT(args.length() == 3);
@@ -2687,7 +2747,7 @@
return -1;
}
-static Object* Runtime_StringLastIndexOf(Arguments args) {
+static MaybeObject* Runtime_StringLastIndexOf(Arguments args) {
HandleScope scope; // create a new handle scope
ASSERT(args.length() == 3);
@@ -2744,7 +2804,7 @@
}
-static Object* Runtime_StringLocaleCompare(Arguments args) {
+static MaybeObject* Runtime_StringLocaleCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -2790,7 +2850,7 @@
}
-static Object* Runtime_SubString(Arguments args) {
+static MaybeObject* Runtime_SubString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -2817,7 +2877,7 @@
}
-static Object* Runtime_StringMatch(Arguments args) {
+static MaybeObject* Runtime_StringMatch(Arguments args) {
ASSERT_EQ(3, args.length());
CONVERT_ARG_CHECKED(String, subject, 0);
@@ -3172,7 +3232,7 @@
}
-static Object* Runtime_RegExpExecMultiple(Arguments args) {
+static MaybeObject* Runtime_RegExpExecMultiple(Arguments args) {
ASSERT(args.length() == 4);
HandleScope handles;
@@ -3221,7 +3281,7 @@
}
-static Object* Runtime_NumberToRadixString(Arguments args) {
+static MaybeObject* Runtime_NumberToRadixString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3252,13 +3312,13 @@
int radix = FastD2I(radix_number);
RUNTIME_ASSERT(2 <= radix && radix <= 36);
char* str = DoubleToRadixCString(value, radix);
- Object* result = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
return result;
}
-static Object* Runtime_NumberToFixed(Arguments args) {
+static MaybeObject* Runtime_NumberToFixed(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3276,13 +3336,13 @@
int f = FastD2I(f_number);
RUNTIME_ASSERT(f >= 0);
char* str = DoubleToFixedCString(value, f);
- Object* res = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
- return res;
+ return result;
}
-static Object* Runtime_NumberToExponential(Arguments args) {
+static MaybeObject* Runtime_NumberToExponential(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3300,13 +3360,13 @@
int f = FastD2I(f_number);
RUNTIME_ASSERT(f >= -1 && f <= 20);
char* str = DoubleToExponentialCString(value, f);
- Object* res = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
- return res;
+ return result;
}
-static Object* Runtime_NumberToPrecision(Arguments args) {
+static MaybeObject* Runtime_NumberToPrecision(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3324,9 +3384,9 @@
int f = FastD2I(f_number);
RUNTIME_ASSERT(f >= 1 && f <= 21);
char* str = DoubleToPrecisionCString(value, f);
- Object* res = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
- return res;
+ return result;
}
@@ -3342,7 +3402,8 @@
}
-Object* Runtime::GetElementOrCharAt(Handle<Object> object, uint32_t index) {
+MaybeObject* Runtime::GetElementOrCharAt(Handle<Object> object,
+ uint32_t index) {
// Handle [] indexing on Strings
if (object->IsString()) {
Handle<Object> result = GetCharAt(Handle<String>::cast(object), index);
@@ -3366,12 +3427,13 @@
}
-Object* Runtime::GetElement(Handle<Object> object, uint32_t index) {
+MaybeObject* Runtime::GetElement(Handle<Object> object, uint32_t index) {
return object->GetElement(index);
}
-Object* Runtime::GetObjectProperty(Handle<Object> object, Handle<Object> key) {
+MaybeObject* Runtime::GetObjectProperty(Handle<Object> object,
+ Handle<Object> key) {
HandleScope scope;
if (object->IsUndefined() || object->IsNull()) {
@@ -3411,7 +3473,7 @@
}
-static Object* Runtime_GetProperty(Arguments args) {
+static MaybeObject* Runtime_GetProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3423,7 +3485,7 @@
// KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric.
-static Object* Runtime_KeyedGetProperty(Arguments args) {
+static MaybeObject* Runtime_KeyedGetProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3488,7 +3550,7 @@
}
-static Object* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
+static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
ASSERT(args.length() == 5);
HandleScope scope;
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -3509,13 +3571,16 @@
if (result.IsProperty() &&
(result.type() == FIELD || result.type() == NORMAL
|| result.type() == CONSTANT_FUNCTION)) {
- Object* ok = obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
- if (ok->IsFailure()) return ok;
+ Object* ok;
+ { MaybeObject* maybe_ok =
+ obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
+ if (!maybe_ok->ToObject(&ok)) return maybe_ok;
+ }
}
return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr);
}
-static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) {
+static MaybeObject* Runtime_DefineOrRedefineDataProperty(Arguments args) {
ASSERT(args.length() == 4);
HandleScope scope;
CONVERT_ARG_CHECKED(JSObject, js_object, 0);
@@ -3569,10 +3634,10 @@
}
-Object* Runtime::SetObjectProperty(Handle<Object> object,
- Handle<Object> key,
- Handle<Object> value,
- PropertyAttributes attr) {
+MaybeObject* Runtime::SetObjectProperty(Handle<Object> object,
+ Handle<Object> key,
+ Handle<Object> value,
+ PropertyAttributes attr) {
HandleScope scope;
if (object->IsUndefined() || object->IsNull()) {
@@ -3634,10 +3699,10 @@
}
-Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
- Handle<Object> key,
- Handle<Object> value,
- PropertyAttributes attr) {
+MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
+ Handle<Object> key,
+ Handle<Object> value,
+ PropertyAttributes attr) {
HandleScope scope;
// Check if the given key is an array index.
@@ -3683,8 +3748,8 @@
}
-Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object,
- Handle<Object> key) {
+MaybeObject* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object,
+ Handle<Object> key) {
HandleScope scope;
// Check if the given key is an array index.
@@ -3719,7 +3784,7 @@
}
-static Object* Runtime_SetProperty(Arguments args) {
+static MaybeObject* Runtime_SetProperty(Arguments args) {
NoHandleAllocation ha;
RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
@@ -3743,7 +3808,7 @@
// Set a local property, even if it is READ_ONLY. If the property does not
// exist, it will be added with attributes NONE.
-static Object* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
+static MaybeObject* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
NoHandleAllocation ha;
RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
CONVERT_CHECKED(JSObject, object, args[0]);
@@ -3764,7 +3829,7 @@
}
-static Object* Runtime_DeleteProperty(Arguments args) {
+static MaybeObject* Runtime_DeleteProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3789,7 +3854,7 @@
}
-static Object* Runtime_HasLocalProperty(Arguments args) {
+static MaybeObject* Runtime_HasLocalProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, key, args[1]);
@@ -3818,7 +3883,7 @@
}
-static Object* Runtime_HasProperty(Arguments args) {
+static MaybeObject* Runtime_HasProperty(Arguments args) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
@@ -3832,7 +3897,7 @@
}
-static Object* Runtime_HasElement(Arguments args) {
+static MaybeObject* Runtime_HasElement(Arguments args) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
@@ -3847,7 +3912,7 @@
}
-static Object* Runtime_IsPropertyEnumerable(Arguments args) {
+static MaybeObject* Runtime_IsPropertyEnumerable(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3864,7 +3929,7 @@
}
-static Object* Runtime_GetPropertyNames(Arguments args) {
+static MaybeObject* Runtime_GetPropertyNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, object, 0);
@@ -3877,7 +3942,7 @@
// all enumerable properties of the object and its prototypes
// have none, the map of the object. This is used to speed up
// the check for deletions during a for-in.
-static Object* Runtime_GetPropertyNamesFast(Arguments args) {
+static MaybeObject* Runtime_GetPropertyNamesFast(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, raw_object, args[0]);
@@ -3913,7 +3978,7 @@
// Return the names of the local named properties.
// args[0]: object
-static Object* Runtime_GetLocalPropertyNames(Arguments args) {
+static MaybeObject* Runtime_GetLocalPropertyNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
@@ -3996,7 +4061,7 @@
// Return the names of the local indexed properties.
// args[0]: object
-static Object* Runtime_GetLocalElementNames(Arguments args) {
+static MaybeObject* Runtime_GetLocalElementNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
@@ -4013,7 +4078,7 @@
// Return information on whether an object has a named or indexed interceptor.
// args[0]: object
-static Object* Runtime_GetInterceptorInfo(Arguments args) {
+static MaybeObject* Runtime_GetInterceptorInfo(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
@@ -4031,7 +4096,7 @@
// Return property names from named interceptor.
// args[0]: object
-static Object* Runtime_GetNamedInterceptorPropertyNames(Arguments args) {
+static MaybeObject* Runtime_GetNamedInterceptorPropertyNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -4046,7 +4111,7 @@
// Return element names from indexed interceptor.
// args[0]: object
-static Object* Runtime_GetIndexedInterceptorElementNames(Arguments args) {
+static MaybeObject* Runtime_GetIndexedInterceptorElementNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -4059,7 +4124,7 @@
}
-static Object* Runtime_LocalKeys(Arguments args) {
+static MaybeObject* Runtime_LocalKeys(Arguments args) {
ASSERT_EQ(args.length(), 1);
CONVERT_CHECKED(JSObject, raw_object, args[0]);
HandleScope scope;
@@ -4087,7 +4152,7 @@
}
-static Object* Runtime_GetArgumentsProperty(Arguments args) {
+static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4132,7 +4197,7 @@
}
-static Object* Runtime_ToFastProperties(Arguments args) {
+static MaybeObject* Runtime_ToFastProperties(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -4140,14 +4205,15 @@
if (object->IsJSObject()) {
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) {
- js_object->TransformToFastProperties(0);
+ MaybeObject* ok = js_object->TransformToFastProperties(0);
+ if (ok->IsRetryAfterGC()) return ok;
}
}
return *object;
}
-static Object* Runtime_ToSlowProperties(Arguments args) {
+static MaybeObject* Runtime_ToSlowProperties(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -4160,7 +4226,7 @@
}
-static Object* Runtime_ToBool(Arguments args) {
+static MaybeObject* Runtime_ToBool(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4170,7 +4236,7 @@
// Returns the type string of a value; see ECMA-262, 11.4.3 (p 47).
// Possible optimizations: put the type string into the oddballs.
-static Object* Runtime_Typeof(Arguments args) {
+static MaybeObject* Runtime_Typeof(Arguments args) {
NoHandleAllocation ha;
Object* obj = args[0];
@@ -4227,7 +4293,7 @@
}
-static Object* Runtime_StringToNumber(Arguments args) {
+static MaybeObject* Runtime_StringToNumber(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(String, subject, args[0]);
@@ -4281,7 +4347,7 @@
}
-static Object* Runtime_StringFromCharCodeArray(Arguments args) {
+static MaybeObject* Runtime_StringFromCharCodeArray(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4291,23 +4357,32 @@
// Check if the string can be ASCII.
int i;
for (i = 0; i < length; i++) {
- Object* element = codes->GetElement(i);
+ Object* element;
+ { MaybeObject* maybe_element = codes->GetElement(i);
+ // We probably can't get an exception here, but just in order to enforce
+ // the checking of inputs in the runtime calls we check here.
+ if (!maybe_element->ToObject(&element)) return maybe_element;
+ }
CONVERT_NUMBER_CHECKED(int, chr, Int32, element);
if ((chr & 0xffff) > String::kMaxAsciiCharCode)
break;
}
- Object* object = NULL;
+ MaybeObject* maybe_object = NULL;
if (i == length) { // The string is ASCII.
- object = Heap::AllocateRawAsciiString(length);
+ maybe_object = Heap::AllocateRawAsciiString(length);
} else { // The string is not ASCII.
- object = Heap::AllocateRawTwoByteString(length);
+ maybe_object = Heap::AllocateRawTwoByteString(length);
}
- if (object->IsFailure()) return object;
+ Object* object = NULL;
+ if (!maybe_object->ToObject(&object)) return maybe_object;
String* result = String::cast(object);
for (int i = 0; i < length; i++) {
- Object* element = codes->GetElement(i);
+ Object* element;
+ { MaybeObject* maybe_element = codes->GetElement(i);
+ if (!maybe_element->ToObject(&element)) return maybe_element;
+ }
CONVERT_NUMBER_CHECKED(int, chr, Int32, element);
result->Set(i, chr & 0xffff);
}
@@ -4352,7 +4427,7 @@
}
-static Object* Runtime_URIEscape(Arguments args) {
+static MaybeObject* Runtime_URIEscape(Arguments args) {
const char hex_chars[] = "0123456789ABCDEF";
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4386,8 +4461,10 @@
if (escaped_length == length) {
return source;
}
- Object* o = Heap::AllocateRawAsciiString(escaped_length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = Heap::AllocateRawAsciiString(escaped_length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
String* destination = String::cast(o);
int dest_position = 0;
@@ -4466,7 +4543,7 @@
}
-static Object* Runtime_URIUnescape(Arguments args) {
+static MaybeObject* Runtime_URIUnescape(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(String, source, args[0]);
@@ -4489,10 +4566,12 @@
if (unescaped_length == length)
return source;
- Object* o = ascii ?
- Heap::AllocateRawAsciiString(unescaped_length) :
- Heap::AllocateRawTwoByteString(unescaped_length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = ascii ?
+ Heap::AllocateRawAsciiString(unescaped_length) :
+ Heap::AllocateRawTwoByteString(unescaped_length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
String* destination = String::cast(o);
int dest_position = 0;
@@ -4505,7 +4584,7 @@
}
-static Object* Runtime_StringParseInt(Arguments args) {
+static MaybeObject* Runtime_StringParseInt(Arguments args) {
NoHandleAllocation ha;
CONVERT_CHECKED(String, s, args[0]);
@@ -4519,7 +4598,7 @@
}
-static Object* Runtime_StringParseFloat(Arguments args) {
+static MaybeObject* Runtime_StringParseFloat(Arguments args) {
NoHandleAllocation ha;
CONVERT_CHECKED(String, str, args[0]);
@@ -4536,10 +4615,11 @@
template <class Converter>
-static Object* ConvertCaseHelper(String* s,
- int length,
- int input_string_length,
- unibrow::Mapping<Converter, 128>* mapping) {
+MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
+ String* s,
+ int length,
+ int input_string_length,
+ unibrow::Mapping<Converter, 128>* mapping) {
// We try this twice, once with the assumption that the result is no longer
// than the input and, if that assumption breaks, again with the exact
// length. This may not be pretty, but it is nicer than what was here before
@@ -4551,10 +4631,12 @@
// character is also ascii. This is currently the case, but it
// might break in the future if we implement more context and locale
// dependent upper/lower conversions.
- Object* o = s->IsAsciiRepresentation()
- ? Heap::AllocateRawAsciiString(length)
- : Heap::AllocateRawTwoByteString(length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = s->IsAsciiRepresentation()
+ ? Heap::AllocateRawAsciiString(length)
+ : Heap::AllocateRawTwoByteString(length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
String* result = String::cast(o);
bool has_changed_character = false;
@@ -4675,7 +4757,7 @@
template <typename ConvertTraits>
-static Object* ConvertCase(
+MUST_USE_RESULT static MaybeObject* ConvertCase(
Arguments args,
unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) {
NoHandleAllocation ha;
@@ -4693,29 +4775,37 @@
// might break in the future if we implement more context and locale
// dependent upper/lower conversions.
if (s->IsSeqAsciiString()) {
- Object* o = Heap::AllocateRawAsciiString(length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = Heap::AllocateRawAsciiString(length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
SeqAsciiString* result = SeqAsciiString::cast(o);
bool has_changed_character = ConvertTraits::ConvertAscii(
result->GetChars(), SeqAsciiString::cast(s)->GetChars(), length);
return has_changed_character ? result : s;
}
- Object* answer = ConvertCaseHelper(s, length, length, mapping);
+ Object* answer;
+ { MaybeObject* maybe_answer = ConvertCaseHelper(s, length, length, mapping);
+ if (!maybe_answer->ToObject(&answer)) return maybe_answer;
+ }
if (answer->IsSmi()) {
// Retry with correct length.
- answer = ConvertCaseHelper(s, Smi::cast(answer)->value(), length, mapping);
+ { MaybeObject* maybe_answer =
+ ConvertCaseHelper(s, Smi::cast(answer)->value(), length, mapping);
+ if (!maybe_answer->ToObject(&answer)) return maybe_answer;
+ }
}
- return answer; // This may be a failure.
+ return answer;
}
-static Object* Runtime_StringToLowerCase(Arguments args) {
+static MaybeObject* Runtime_StringToLowerCase(Arguments args) {
return ConvertCase<ToLowerTraits>(args, &to_lower_mapping);
}
-static Object* Runtime_StringToUpperCase(Arguments args) {
+static MaybeObject* Runtime_StringToUpperCase(Arguments args) {
return ConvertCase<ToUpperTraits>(args, &to_upper_mapping);
}
@@ -4725,7 +4815,7 @@
}
-static Object* Runtime_StringTrim(Arguments args) {
+static MaybeObject* Runtime_StringTrim(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -4774,7 +4864,7 @@
}
-static Object* Runtime_StringSplit(Arguments args) {
+static MaybeObject* Runtime_StringSplit(Arguments args) {
ASSERT(args.length() == 3);
HandleScope handle_scope;
CONVERT_ARG_CHECKED(String, subject, 0);
@@ -4900,7 +4990,7 @@
// Converts a String to JSArray.
// For example, "foo" => ["f", "o", "o"].
-static Object* Runtime_StringToArray(Arguments args) {
+static MaybeObject* Runtime_StringToArray(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(String, s, 0);
@@ -4910,8 +5000,10 @@
Handle<FixedArray> elements;
if (s->IsFlat() && s->IsAsciiRepresentation()) {
- Object* obj = Heap::AllocateUninitializedFixedArray(length);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = Heap::AllocateUninitializedFixedArray(length);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
elements = Handle<FixedArray>(FixedArray::cast(obj));
Vector<const char> chars = s->ToAsciiVector();
@@ -4943,7 +5035,7 @@
}
-static Object* Runtime_NewStringWrapper(Arguments args) {
+static MaybeObject* Runtime_NewStringWrapper(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(String, value, args[0]);
@@ -4958,7 +5050,7 @@
}
-static Object* Runtime_NumberToString(Arguments args) {
+static MaybeObject* Runtime_NumberToString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4969,7 +5061,7 @@
}
-static Object* Runtime_NumberToStringSkipCache(Arguments args) {
+static MaybeObject* Runtime_NumberToStringSkipCache(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4980,7 +5072,7 @@
}
-static Object* Runtime_NumberToInteger(Arguments args) {
+static MaybeObject* Runtime_NumberToInteger(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4994,7 +5086,7 @@
}
-static Object* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
+static MaybeObject* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5013,7 +5105,7 @@
}
-static Object* Runtime_NumberToJSUint32(Arguments args) {
+static MaybeObject* Runtime_NumberToJSUint32(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5022,7 +5114,7 @@
}
-static Object* Runtime_NumberToJSInt32(Arguments args) {
+static MaybeObject* Runtime_NumberToJSInt32(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5038,7 +5130,7 @@
// Converts a Number to a Smi, if possible. Returns NaN if the number is not
// a small integer.
-static Object* Runtime_NumberToSmi(Arguments args) {
+static MaybeObject* Runtime_NumberToSmi(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5057,7 +5149,7 @@
}
-static Object* Runtime_NumberAdd(Arguments args) {
+static MaybeObject* Runtime_NumberAdd(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5067,7 +5159,7 @@
}
-static Object* Runtime_NumberSub(Arguments args) {
+static MaybeObject* Runtime_NumberSub(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5077,7 +5169,7 @@
}
-static Object* Runtime_NumberMul(Arguments args) {
+static MaybeObject* Runtime_NumberMul(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5087,7 +5179,7 @@
}
-static Object* Runtime_NumberUnaryMinus(Arguments args) {
+static MaybeObject* Runtime_NumberUnaryMinus(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5096,7 +5188,7 @@
}
-static Object* Runtime_NumberAlloc(Arguments args) {
+static MaybeObject* Runtime_NumberAlloc(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
@@ -5104,7 +5196,7 @@
}
-static Object* Runtime_NumberDiv(Arguments args) {
+static MaybeObject* Runtime_NumberDiv(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5114,7 +5206,7 @@
}
-static Object* Runtime_NumberMod(Arguments args) {
+static MaybeObject* Runtime_NumberMod(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5127,7 +5219,7 @@
}
-static Object* Runtime_StringAdd(Arguments args) {
+static MaybeObject* Runtime_StringAdd(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, str1, args[0]);
@@ -5176,7 +5268,7 @@
}
-static Object* Runtime_StringBuilderConcat(Arguments args) {
+static MaybeObject* Runtime_StringBuilderConcat(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
CONVERT_CHECKED(JSArray, array, args[0]);
@@ -5264,8 +5356,9 @@
Object* object;
if (ascii) {
- object = Heap::AllocateRawAsciiString(length);
- if (object->IsFailure()) return object;
+ { MaybeObject* maybe_object = Heap::AllocateRawAsciiString(length);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
SeqAsciiString* answer = SeqAsciiString::cast(object);
StringBuilderConcatHelper(special,
answer->GetChars(),
@@ -5273,8 +5366,9 @@
array_length);
return answer;
} else {
- object = Heap::AllocateRawTwoByteString(length);
- if (object->IsFailure()) return object;
+ { MaybeObject* maybe_object = Heap::AllocateRawTwoByteString(length);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
SeqTwoByteString* answer = SeqTwoByteString::cast(object);
StringBuilderConcatHelper(special,
answer->GetChars(),
@@ -5285,7 +5379,7 @@
}
-static Object* Runtime_NumberOr(Arguments args) {
+static MaybeObject* Runtime_NumberOr(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5295,7 +5389,7 @@
}
-static Object* Runtime_NumberAnd(Arguments args) {
+static MaybeObject* Runtime_NumberAnd(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5305,7 +5399,7 @@
}
-static Object* Runtime_NumberXor(Arguments args) {
+static MaybeObject* Runtime_NumberXor(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5315,7 +5409,7 @@
}
-static Object* Runtime_NumberNot(Arguments args) {
+static MaybeObject* Runtime_NumberNot(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5324,7 +5418,7 @@
}
-static Object* Runtime_NumberShl(Arguments args) {
+static MaybeObject* Runtime_NumberShl(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5334,7 +5428,7 @@
}
-static Object* Runtime_NumberShr(Arguments args) {
+static MaybeObject* Runtime_NumberShr(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5344,7 +5438,7 @@
}
-static Object* Runtime_NumberSar(Arguments args) {
+static MaybeObject* Runtime_NumberSar(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5354,7 +5448,7 @@
}
-static Object* Runtime_NumberEquals(Arguments args) {
+static MaybeObject* Runtime_NumberEquals(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5373,7 +5467,7 @@
}
-static Object* Runtime_StringEquals(Arguments args) {
+static MaybeObject* Runtime_StringEquals(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5391,7 +5485,7 @@
}
-static Object* Runtime_NumberCompare(Arguments args) {
+static MaybeObject* Runtime_NumberCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -5406,7 +5500,7 @@
// Compare two Smis as if they were converted to strings and then
// compared lexicographically.
-static Object* Runtime_SmiLexicographicCompare(Arguments args) {
+static MaybeObject* Runtime_SmiLexicographicCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5524,7 +5618,7 @@
}
-static Object* Runtime_StringCompare(Arguments args) {
+static MaybeObject* Runtime_StringCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5546,17 +5640,20 @@
if (d < 0) return Smi::FromInt(LESS);
else if (d > 0) return Smi::FromInt(GREATER);
- Object* obj = Heap::PrepareForCompare(x);
- if (obj->IsFailure()) return obj;
- obj = Heap::PrepareForCompare(y);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = Heap::PrepareForCompare(x);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
+ { MaybeObject* maybe_obj = Heap::PrepareForCompare(y);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
: StringInputBufferCompare(x, y);
}
-static Object* Runtime_Math_acos(Arguments args) {
+static MaybeObject* Runtime_Math_acos(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_acos.Increment();
@@ -5566,7 +5663,7 @@
}
-static Object* Runtime_Math_asin(Arguments args) {
+static MaybeObject* Runtime_Math_asin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_asin.Increment();
@@ -5576,7 +5673,7 @@
}
-static Object* Runtime_Math_atan(Arguments args) {
+static MaybeObject* Runtime_Math_atan(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_atan.Increment();
@@ -5586,7 +5683,7 @@
}
-static Object* Runtime_Math_atan2(Arguments args) {
+static MaybeObject* Runtime_Math_atan2(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
Counters::math_atan2.Increment();
@@ -5610,7 +5707,7 @@
}
-static Object* Runtime_Math_ceil(Arguments args) {
+static MaybeObject* Runtime_Math_ceil(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_ceil.Increment();
@@ -5620,7 +5717,7 @@
}
-static Object* Runtime_Math_cos(Arguments args) {
+static MaybeObject* Runtime_Math_cos(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_cos.Increment();
@@ -5630,7 +5727,7 @@
}
-static Object* Runtime_Math_exp(Arguments args) {
+static MaybeObject* Runtime_Math_exp(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_exp.Increment();
@@ -5640,7 +5737,7 @@
}
-static Object* Runtime_Math_floor(Arguments args) {
+static MaybeObject* Runtime_Math_floor(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_floor.Increment();
@@ -5650,7 +5747,7 @@
}
-static Object* Runtime_Math_log(Arguments args) {
+static MaybeObject* Runtime_Math_log(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_log.Increment();
@@ -5691,7 +5788,7 @@
}
-static Object* Runtime_Math_pow(Arguments args) {
+static MaybeObject* Runtime_Math_pow(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
Counters::math_pow.Increment();
@@ -5731,7 +5828,7 @@
// Fast version of Math.pow if we know that y is not an integer and
// y is not -0.5 or 0.5. Used as slowcase from codegen.
-static Object* Runtime_Math_pow_cfunction(Arguments args) {
+static MaybeObject* Runtime_Math_pow_cfunction(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_DOUBLE_CHECKED(x, args[0]);
@@ -5746,7 +5843,7 @@
}
-static Object* Runtime_RoundNumber(Arguments args) {
+static MaybeObject* Runtime_RoundNumber(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_round.Increment();
@@ -5782,7 +5879,7 @@
}
-static Object* Runtime_Math_sin(Arguments args) {
+static MaybeObject* Runtime_Math_sin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_sin.Increment();
@@ -5792,7 +5889,7 @@
}
-static Object* Runtime_Math_sqrt(Arguments args) {
+static MaybeObject* Runtime_Math_sqrt(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_sqrt.Increment();
@@ -5802,7 +5899,7 @@
}
-static Object* Runtime_Math_tan(Arguments args) {
+static MaybeObject* Runtime_Math_tan(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_tan.Increment();
@@ -5857,7 +5954,7 @@
}
-static Object* Runtime_DateMakeDay(Arguments args) {
+static MaybeObject* Runtime_DateMakeDay(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -6156,7 +6253,7 @@
}
-static Object* Runtime_DateYMDFromTime(Arguments args) {
+static MaybeObject* Runtime_DateYMDFromTime(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -6178,7 +6275,7 @@
}
-static Object* Runtime_NewArgumentsFast(Arguments args) {
+static MaybeObject* Runtime_NewArgumentsFast(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -6186,13 +6283,17 @@
Object** parameters = reinterpret_cast<Object**>(args[1]);
const int length = Smi::cast(args[2])->value();
- Object* result = Heap::AllocateArgumentsObject(callee, length);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateArgumentsObject(callee, length);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
// Allocate the elements if needed.
if (length > 0) {
// Allocate the fixed array.
- Object* obj = Heap::AllocateRawFixedArray(length);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = Heap::AllocateRawFixedArray(length);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
AssertNoAllocation no_gc;
FixedArray* array = reinterpret_cast<FixedArray*>(obj);
@@ -6209,7 +6310,7 @@
}
-static Object* Runtime_NewClosure(Arguments args) {
+static MaybeObject* Runtime_NewClosure(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(Context, context, 0);
@@ -6223,7 +6324,7 @@
return *result;
}
-static Object* Runtime_NewObjectFromBound(Arguments args) {
+static MaybeObject* Runtime_NewObjectFromBound(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -6257,15 +6358,16 @@
}
if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
ConstructStubCompiler compiler;
- Object* code = compiler.CompileConstructStub(function->shared());
+ MaybeObject* code = compiler.CompileConstructStub(function->shared());
if (!code->IsFailure()) {
- function->shared()->set_construct_stub(Code::cast(code));
+ function->shared()->set_construct_stub(
+ Code::cast(code->ToObjectUnchecked()));
}
}
}
-static Object* Runtime_NewObject(Arguments args) {
+static MaybeObject* Runtime_NewObject(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6341,7 +6443,7 @@
}
-static Object* Runtime_FinalizeInstanceSize(Arguments args) {
+static MaybeObject* Runtime_FinalizeInstanceSize(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6353,7 +6455,7 @@
}
-static Object* Runtime_LazyCompile(Arguments args) {
+static MaybeObject* Runtime_LazyCompile(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6382,7 +6484,7 @@
}
-static Object* Runtime_GetFunctionDelegate(Arguments args) {
+static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
RUNTIME_ASSERT(!args[0]->IsJSFunction());
@@ -6390,7 +6492,7 @@
}
-static Object* Runtime_GetConstructorDelegate(Arguments args) {
+static MaybeObject* Runtime_GetConstructorDelegate(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
RUNTIME_ASSERT(!args[0]->IsJSFunction());
@@ -6398,27 +6500,33 @@
}
-static Object* Runtime_NewContext(Arguments args) {
+static MaybeObject* Runtime_NewContext(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, function, args[0]);
int length = function->shared()->scope_info()->NumberOfContextSlots();
- Object* result = Heap::AllocateFunctionContext(length, function);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateFunctionContext(length, function);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
Top::set_context(Context::cast(result));
return result; // non-failure
}
-static Object* PushContextHelper(Object* object, bool is_catch_context) {
+
+MUST_USE_RESULT static MaybeObject* PushContextHelper(Object* object,
+ bool is_catch_context) {
// Convert the object to a proper JavaScript object.
Object* js_object = object;
if (!js_object->IsJSObject()) {
- js_object = js_object->ToObject();
- if (js_object->IsFailure()) {
- if (!Failure::cast(js_object)->IsInternalError()) return js_object;
+ MaybeObject* maybe_js_object = js_object->ToObject();
+ if (!maybe_js_object->ToObject(&js_object)) {
+ if (!Failure::cast(maybe_js_object)->IsInternalError()) {
+ return maybe_js_object;
+ }
HandleScope scope;
Handle<Object> handle(object);
Handle<Object> result =
@@ -6427,11 +6535,13 @@
}
}
- Object* result =
- Heap::AllocateWithContext(Top::context(),
- JSObject::cast(js_object),
- is_catch_context);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result =
+ Heap::AllocateWithContext(Top::context(),
+ JSObject::cast(js_object),
+ is_catch_context);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
Context* context = Context::cast(result);
Top::set_context(context);
@@ -6440,21 +6550,21 @@
}
-static Object* Runtime_PushContext(Arguments args) {
+static MaybeObject* Runtime_PushContext(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
return PushContextHelper(args[0], false);
}
-static Object* Runtime_PushCatchContext(Arguments args) {
+static MaybeObject* Runtime_PushCatchContext(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
return PushContextHelper(args[0], true);
}
-static Object* Runtime_LookupContext(Arguments args) {
+static MaybeObject* Runtime_LookupContext(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -6487,11 +6597,11 @@
// allocated by the caller, and passed as a pointer in a hidden first parameter.
#ifdef V8_HOST_ARCH_64_BIT
struct ObjectPair {
- Object* x;
- Object* y;
+ MaybeObject* x;
+ MaybeObject* y;
};
-static inline ObjectPair MakePair(Object* x, Object* y) {
+static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
ObjectPair result = {x, y};
// Pointers x and y returned in rax and rdx, in AMD-x64-abi.
// In Win64 they are assigned to a hidden first argument.
@@ -6499,14 +6609,15 @@
}
#else
typedef uint64_t ObjectPair;
-static inline ObjectPair MakePair(Object* x, Object* y) {
+static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
return reinterpret_cast<uint32_t>(x) |
(reinterpret_cast<ObjectPair>(y) << 32);
}
#endif
-static inline Object* Unhole(Object* x, PropertyAttributes attributes) {
+static inline MaybeObject* Unhole(MaybeObject* x,
+ PropertyAttributes attributes) {
ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0);
USE(attributes);
return x->IsTheHole() ? Heap::undefined_value() : x;
@@ -6556,7 +6667,7 @@
// argument in a context, the receiver is the global object; see
// ECMA-262, 3rd., 10.1.6 and 10.2.3.
JSObject* receiver = Top::context()->global()->global_receiver();
- Object* value = (holder->IsContext())
+ MaybeObject* value = (holder->IsContext())
? Context::cast(*holder)->get(index)
: JSObject::cast(*holder)->GetElement(index);
return MakePair(Unhole(value, attributes), receiver);
@@ -6576,7 +6687,7 @@
}
// No need to unhole the value here. This is taken care of by the
// GetProperty function.
- Object* value = object->GetProperty(*name);
+ MaybeObject* value = object->GetProperty(*name);
return MakePair(value, receiver);
}
@@ -6602,7 +6713,7 @@
}
-static Object* Runtime_StoreContextSlot(Arguments args) {
+static MaybeObject* Runtime_StoreContextSlot(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
@@ -6624,10 +6735,8 @@
}
} else {
ASSERT((attributes & READ_ONLY) == 0);
- Object* result =
- Handle<JSObject>::cast(holder)->SetElement(index, *value);
- USE(result);
- ASSERT(!result->IsFailure());
+ Handle<JSObject>::cast(holder)->SetElement(index, *value)->
+ ToObjectUnchecked();
}
return *value;
}
@@ -6663,7 +6772,7 @@
}
-static Object* Runtime_Throw(Arguments args) {
+static MaybeObject* Runtime_Throw(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6671,7 +6780,7 @@
}
-static Object* Runtime_ReThrow(Arguments args) {
+static MaybeObject* Runtime_ReThrow(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6679,13 +6788,13 @@
}
-static Object* Runtime_PromoteScheduledException(Arguments args) {
+static MaybeObject* Runtime_PromoteScheduledException(Arguments args) {
ASSERT_EQ(0, args.length());
return Top::PromoteScheduledException();
}
-static Object* Runtime_ThrowReferenceError(Arguments args) {
+static MaybeObject* Runtime_ThrowReferenceError(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6696,13 +6805,13 @@
}
-static Object* Runtime_StackOverflow(Arguments args) {
+static MaybeObject* Runtime_StackOverflow(Arguments args) {
NoHandleAllocation na;
return Top::StackOverflow();
}
-static Object* Runtime_StackGuard(Arguments args) {
+static MaybeObject* Runtime_StackGuard(Arguments args) {
ASSERT(args.length() == 0);
// First check if this is a real stack overflow.
@@ -6800,7 +6909,7 @@
}
-static Object* Runtime_TraceEnter(Arguments args) {
+static MaybeObject* Runtime_TraceEnter(Arguments args) {
ASSERT(args.length() == 0);
NoHandleAllocation ha;
PrintTransition(NULL);
@@ -6808,14 +6917,14 @@
}
-static Object* Runtime_TraceExit(Arguments args) {
+static MaybeObject* Runtime_TraceExit(Arguments args) {
NoHandleAllocation ha;
PrintTransition(args[0]);
return args[0]; // return TOS
}
-static Object* Runtime_DebugPrint(Arguments args) {
+static MaybeObject* Runtime_DebugPrint(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -6846,7 +6955,7 @@
}
-static Object* Runtime_DebugTrace(Arguments args) {
+static MaybeObject* Runtime_DebugTrace(Arguments args) {
ASSERT(args.length() == 0);
NoHandleAllocation ha;
Top::PrintStack();
@@ -6854,7 +6963,7 @@
}
-static Object* Runtime_DateCurrentTime(Arguments args) {
+static MaybeObject* Runtime_DateCurrentTime(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
@@ -6867,7 +6976,7 @@
}
-static Object* Runtime_DateParseString(Arguments args) {
+static MaybeObject* Runtime_DateParseString(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -6897,7 +7006,7 @@
}
-static Object* Runtime_DateLocalTimezone(Arguments args) {
+static MaybeObject* Runtime_DateLocalTimezone(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -6907,7 +7016,7 @@
}
-static Object* Runtime_DateLocalTimeOffset(Arguments args) {
+static MaybeObject* Runtime_DateLocalTimeOffset(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
@@ -6915,7 +7024,7 @@
}
-static Object* Runtime_DateDaylightSavingsOffset(Arguments args) {
+static MaybeObject* Runtime_DateDaylightSavingsOffset(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -6924,7 +7033,7 @@
}
-static Object* Runtime_GlobalReceiver(Arguments args) {
+static MaybeObject* Runtime_GlobalReceiver(Arguments args) {
ASSERT(args.length() == 1);
Object* global = args[0];
if (!global->IsJSGlobalObject()) return Heap::null_value();
@@ -6932,7 +7041,7 @@
}
-static Object* Runtime_CompileString(Arguments args) {
+static MaybeObject* Runtime_CompileString(Arguments args) {
HandleScope scope;
ASSERT_EQ(2, args.length());
CONVERT_ARG_CHECKED(String, source, 0);
@@ -7060,7 +7169,7 @@
}
-static Object* Runtime_SetNewFunctionAttributes(Arguments args) {
+static MaybeObject* Runtime_SetNewFunctionAttributes(Arguments args) {
// This utility adjusts the property attributes for newly created Function
// object ("new Function(...)") by changing the map.
// All it does is changing the prototype property to enumerable
@@ -7077,7 +7186,7 @@
}
-static Object* Runtime_AllocateInNewSpace(Arguments args) {
+static MaybeObject* Runtime_AllocateInNewSpace(Arguments args) {
// Allocate a block of memory in NewSpace (filled with a filler).
// Use as fallback for allocation in generated code when NewSpace
// is full.
@@ -7089,18 +7198,20 @@
static const int kMinFreeNewSpaceAfterGC =
Heap::InitialSemiSpaceSize() * 3/4;
RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC);
- Object* allocation = Heap::new_space()->AllocateRaw(size);
- if (!allocation->IsFailure()) {
- Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
+ Object* allocation;
+ { MaybeObject* maybe_allocation = Heap::new_space()->AllocateRaw(size);
+ if (maybe_allocation->ToObject(&allocation)) {
+ Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
+ }
+ return maybe_allocation;
}
- return allocation;
}
// Push an array unto an array of arrays if it is not already in the
// array. Returns true if the element was pushed on the stack and
// false otherwise.
-static Object* Runtime_PushIfAbsent(Arguments args) {
+static MaybeObject* Runtime_PushIfAbsent(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSArray, array, args[0]);
CONVERT_CHECKED(JSArray, element, args[1]);
@@ -7110,8 +7221,10 @@
for (int i = 0; i < length; i++) {
if (elements->get(i) == element) return Heap::false_value();
}
- Object* obj = array->SetFastElement(length, element);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = array->SetFastElement(length, element);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return Heap::true_value();
}
@@ -7405,31 +7518,37 @@
uint32_t num_of_args = static_cast<uint32_t>(arguments->length()->Number());
for (uint32_t i = 0; i < num_of_args; i++) {
- Handle<Object> obj(arguments->GetElement(i));
- if (obj->IsJSArray()) {
- Handle<JSArray> array = Handle<JSArray>::cast(obj);
- uint32_t len = static_cast<uint32_t>(array->length()->Number());
- uint32_t nof_elements =
- IterateArrayAndPrototypeElements(array, visitor);
- // Total elements of array and its prototype chain can be more than
- // the array length, but ArrayConcat can only concatenate at most
- // the array length number of elements. We use the length as an estimate
- // for the actual number of elements added.
- uint32_t added_elements = (nof_elements > len) ? len : nof_elements;
- if (JSArray::kMaxElementCount - visited_elements < added_elements) {
- visited_elements = JSArray::kMaxElementCount;
+ Object *element;
+ MaybeObject* maybe_element = arguments->GetElement(i);
+ // This if() is not expected to fail, but we have the check in the
+ // interest of hardening the runtime calls.
+ if (maybe_element->ToObject(&element)) {
+ Handle<Object> obj(element);
+ if (obj->IsJSArray()) {
+ Handle<JSArray> array = Handle<JSArray>::cast(obj);
+ uint32_t len = static_cast<uint32_t>(array->length()->Number());
+ uint32_t nof_elements =
+ IterateArrayAndPrototypeElements(array, visitor);
+ // Total elements of array and its prototype chain can be more than
+ // the array length, but ArrayConcat can only concatenate at most
+ // the array length number of elements. We use the length as an estimate
+ // for the actual number of elements added.
+ uint32_t added_elements = (nof_elements > len) ? len : nof_elements;
+ if (JSArray::kMaxElementCount - visited_elements < added_elements) {
+ visited_elements = JSArray::kMaxElementCount;
+ } else {
+ visited_elements += added_elements;
+ }
+ if (visitor) visitor->increase_index_offset(len);
} else {
- visited_elements += added_elements;
+ if (visitor) {
+ visitor->visit(0, obj);
+ visitor->increase_index_offset(1);
+ }
+ if (visited_elements < JSArray::kMaxElementCount) {
+ visited_elements++;
+ }
}
- if (visitor) visitor->increase_index_offset(len);
- } else {
- if (visitor) {
- visitor->visit(0, obj);
- visitor->increase_index_offset(1);
- }
- if (visited_elements < JSArray::kMaxElementCount) {
- visited_elements++;
- }
}
}
return visited_elements;
@@ -7442,7 +7561,7 @@
* TODO(lrn): Fix non-compliance for very large concatenations and update to
* following the ECMAScript 5 specification.
*/
-static Object* Runtime_ArrayConcat(Arguments args) {
+static MaybeObject* Runtime_ArrayConcat(Arguments args) {
ASSERT(args.length() == 1);
HandleScope handle_scope;
@@ -7456,19 +7575,24 @@
{ AssertNoAllocation nogc;
for (uint32_t i = 0; i < num_of_args; i++) {
- Object* obj = arguments->GetElement(i);
- uint32_t length_estimate;
- if (obj->IsJSArray()) {
- length_estimate =
- static_cast<uint32_t>(JSArray::cast(obj)->length()->Number());
- } else {
- length_estimate = 1;
+ Object* obj;
+ MaybeObject* maybe_object = arguments->GetElement(i);
+ // This if() is not expected to fail, but we have the check in the
+ // interest of hardening the runtime calls.
+ if (maybe_object->ToObject(&obj)) {
+ uint32_t length_estimate;
+ if (obj->IsJSArray()) {
+ length_estimate =
+ static_cast<uint32_t>(JSArray::cast(obj)->length()->Number());
+ } else {
+ length_estimate = 1;
+ }
+ if (JSObject::kMaxElementCount - result_length < length_estimate) {
+ result_length = JSObject::kMaxElementCount;
+ break;
+ }
+ result_length += length_estimate;
}
- if (JSObject::kMaxElementCount - result_length < length_estimate) {
- result_length = JSObject::kMaxElementCount;
- break;
- }
- result_length += length_estimate;
}
}
@@ -7516,7 +7640,7 @@
// This will not allocate (flatten the string), but it may run
// very slowly for very deeply nested ConsStrings. For debugging use only.
-static Object* Runtime_GlobalPrint(Arguments args) {
+static MaybeObject* Runtime_GlobalPrint(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -7534,7 +7658,7 @@
// and are followed by non-existing element. Does not change the length
// property.
// Returns the number of non-undefined elements collected.
-static Object* Runtime_RemoveArrayHoles(Arguments args) {
+static MaybeObject* Runtime_RemoveArrayHoles(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSObject, object, args[0]);
CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
@@ -7543,31 +7667,34 @@
// Move contents of argument 0 (an array) to argument 1 (an array)
-static Object* Runtime_MoveArrayContents(Arguments args) {
+static MaybeObject* Runtime_MoveArrayContents(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSArray, from, args[0]);
CONVERT_CHECKED(JSArray, to, args[1]);
HeapObject* new_elements = from->elements();
- Object* new_map;
+ MaybeObject* maybe_new_map;
if (new_elements->map() == Heap::fixed_array_map() ||
new_elements->map() == Heap::fixed_cow_array_map()) {
- new_map = to->map()->GetFastElementsMap();
+ maybe_new_map = to->map()->GetFastElementsMap();
} else {
- new_map = to->map()->GetSlowElementsMap();
+ maybe_new_map = to->map()->GetSlowElementsMap();
}
- if (new_map->IsFailure()) return new_map;
+ Object* new_map;
+ if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
to->set_map(Map::cast(new_map));
to->set_elements(new_elements);
to->set_length(from->length());
- Object* obj = from->ResetElements();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = from->ResetElements();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
from->set_length(Smi::FromInt(0));
return to;
}
// How many elements does this object/array have?
-static Object* Runtime_EstimateNumberOfElements(Arguments args) {
+static MaybeObject* Runtime_EstimateNumberOfElements(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, object, args[0]);
HeapObject* elements = object->elements();
@@ -7581,7 +7708,7 @@
}
-static Object* Runtime_SwapElements(Arguments args) {
+static MaybeObject* Runtime_SwapElements(Arguments args) {
HandleScope handle_scope;
ASSERT_EQ(3, args.length());
@@ -7612,7 +7739,7 @@
// intervals (pair of a negative integer (-start-1) followed by a
// positive (length)) or undefined values.
// Intervals can span over some keys that are not in the object.
-static Object* Runtime_GetArrayKeys(Arguments args) {
+static MaybeObject* Runtime_GetArrayKeys(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSObject, array, 0);
@@ -7652,7 +7779,7 @@
// to the way accessors are implemented, it is set for both the getter
// and setter on the first call to DefineAccessor and ignored on
// subsequent calls.
-static Object* Runtime_DefineAccessor(Arguments args) {
+static MaybeObject* Runtime_DefineAccessor(Arguments args) {
RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
// Compute attributes.
PropertyAttributes attributes = NONE;
@@ -7672,7 +7799,7 @@
}
-static Object* Runtime_LookupAccessor(Arguments args) {
+static MaybeObject* Runtime_LookupAccessor(Arguments args) {
ASSERT(args.length() == 3);
CONVERT_CHECKED(JSObject, obj, args[0]);
CONVERT_CHECKED(String, name, args[1]);
@@ -7682,7 +7809,7 @@
#ifdef ENABLE_DEBUGGER_SUPPORT
-static Object* Runtime_DebugBreak(Arguments args) {
+static MaybeObject* Runtime_DebugBreak(Arguments args) {
ASSERT(args.length() == 0);
return Execution::DebugBreakHelper();
}
@@ -7704,7 +7831,7 @@
// args[0]: debug event listener function to set or null or undefined for
// clearing the event listener function
// args[1]: object supplied during callback
-static Object* Runtime_SetDebugEventListener(Arguments args) {
+static MaybeObject* Runtime_SetDebugEventListener(Arguments args) {
ASSERT(args.length() == 2);
RUNTIME_ASSERT(args[0]->IsJSFunction() ||
args[0]->IsUndefined() ||
@@ -7717,16 +7844,16 @@
}
-static Object* Runtime_Break(Arguments args) {
+static MaybeObject* Runtime_Break(Arguments args) {
ASSERT(args.length() == 0);
StackGuard::DebugBreak();
return Heap::undefined_value();
}
-static Object* DebugLookupResultValue(Object* receiver, String* name,
- LookupResult* result,
- bool* caught_exception) {
+static MaybeObject* DebugLookupResultValue(Object* receiver, String* name,
+ LookupResult* result,
+ bool* caught_exception) {
Object* value;
switch (result->type()) {
case NORMAL:
@@ -7748,14 +7875,16 @@
case CALLBACKS: {
Object* structure = result->GetCallbackObject();
if (structure->IsProxy() || structure->IsAccessorInfo()) {
- value = receiver->GetPropertyWithCallback(
+ MaybeObject* maybe_value = receiver->GetPropertyWithCallback(
receiver, structure, name, result->holder());
- if (value->IsException()) {
- value = Top::pending_exception();
+ if (!maybe_value->ToObject(&value)) {
+ ASSERT(maybe_value->IsException());
+ maybe_value = Top::pending_exception();
Top::clear_pending_exception();
if (caught_exception != NULL) {
*caught_exception = true;
}
+ return maybe_value;
}
return value;
} else {
@@ -7787,7 +7916,7 @@
// 4: Setter function if defined
// Items 2-4 are only filled if the property has either a getter or a setter
// defined through __defineGetter__ and/or __defineSetter__.
-static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
+static MaybeObject* Runtime_DebugGetPropertyDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -7818,7 +7947,13 @@
uint32_t index;
if (name->AsArrayIndex(&index)) {
Handle<FixedArray> details = Factory::NewFixedArray(2);
- Object* element_or_char = Runtime::GetElementOrCharAt(obj, index);
+ Object* element_or_char;
+ { MaybeObject* maybe_element_or_char =
+ Runtime::GetElementOrCharAt(obj, index);
+ if (!maybe_element_or_char->ToObject(&element_or_char)) {
+ return maybe_element_or_char;
+ }
+ }
details->set(0, element_or_char);
details->set(1, PropertyDetails(NONE, NORMAL).AsSmi());
return *Factory::NewJSArrayWithElements(details);
@@ -7845,9 +7980,11 @@
// DebugLookupResultValue can cause GC so details from LookupResult needs
// to be copied to handles before this.
bool caught_exception = false;
- Object* raw_value = DebugLookupResultValue(*obj, *name, &result,
- &caught_exception);
- if (raw_value->IsFailure()) return raw_value;
+ Object* raw_value;
+ { MaybeObject* maybe_raw_value =
+ DebugLookupResultValue(*obj, *name, &result, &caught_exception);
+ if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value;
+ }
Handle<Object> value(raw_value);
// If the callback object is a fixed array then it contains JavaScript
@@ -7877,7 +8014,7 @@
}
-static Object* Runtime_DebugGetProperty(Arguments args) {
+static MaybeObject* Runtime_DebugGetProperty(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -7896,7 +8033,7 @@
// Return the property type calculated from the property details.
// args[0]: smi with property details.
-static Object* Runtime_DebugPropertyTypeFromDetails(Arguments args) {
+static MaybeObject* Runtime_DebugPropertyTypeFromDetails(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(Smi, details, args[0]);
PropertyType type = PropertyDetails(details).type();
@@ -7906,7 +8043,7 @@
// Return the property attribute calculated from the property details.
// args[0]: smi with property details.
-static Object* Runtime_DebugPropertyAttributesFromDetails(Arguments args) {
+static MaybeObject* Runtime_DebugPropertyAttributesFromDetails(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(Smi, details, args[0]);
PropertyAttributes attributes = PropertyDetails(details).attributes();
@@ -7916,7 +8053,7 @@
// Return the property insertion index calculated from the property details.
// args[0]: smi with property details.
-static Object* Runtime_DebugPropertyIndexFromDetails(Arguments args) {
+static MaybeObject* Runtime_DebugPropertyIndexFromDetails(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(Smi, details, args[0]);
int index = PropertyDetails(details).index();
@@ -7927,7 +8064,7 @@
// Return property value from named interceptor.
// args[0]: object
// args[1]: property name
-static Object* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) {
+static MaybeObject* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -7942,7 +8079,8 @@
// Return element value from indexed interceptor.
// args[0]: object
// args[1]: index
-static Object* Runtime_DebugIndexedInterceptorElementValue(Arguments args) {
+static MaybeObject* Runtime_DebugIndexedInterceptorElementValue(
+ Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -7953,7 +8091,7 @@
}
-static Object* Runtime_CheckExecutionState(Arguments args) {
+static MaybeObject* Runtime_CheckExecutionState(Arguments args) {
ASSERT(args.length() >= 1);
CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
// Check that the break id is valid.
@@ -7965,13 +8103,15 @@
}
-static Object* Runtime_GetFrameCount(Arguments args) {
+static MaybeObject* Runtime_GetFrameCount(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
// Check arguments.
- Object* result = Runtime_CheckExecutionState(args);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
// Count all frames which are relevant to debugging stack trace.
int n = 0;
@@ -8013,13 +8153,15 @@
// Arguments name, value
// Locals name, value
// Return value if any
-static Object* Runtime_GetFrameDetails(Arguments args) {
+static MaybeObject* Runtime_GetFrameDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
// Find the relevant frame with the requested index.
@@ -8320,9 +8462,12 @@
Handle<JSObject> arguments_shadow(
JSObject::cast(context->get(arguments_shadow_index)));
for (int i = 0; i < scope_info.number_of_parameters(); ++i) {
+ // We don't expect exception-throwing getters on the arguments shadow.
+ Object* element = arguments_shadow->GetElement(i)->ToObjectUnchecked();
SetProperty(closure_scope,
scope_info.parameter_name(i),
- Handle<Object>(arguments_shadow->GetElement(i)), NONE);
+ Handle<Object>(element),
+ NONE);
}
}
@@ -8554,13 +8699,15 @@
};
-static Object* Runtime_GetScopeCount(Arguments args) {
+static MaybeObject* Runtime_GetScopeCount(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
// Get the frame where the debugging is performed.
@@ -8590,13 +8737,15 @@
// The array returned contains the following information:
// 0: Scope type
// 1: Scope object
-static Object* Runtime_GetScopeDetails(Arguments args) {
+static MaybeObject* Runtime_GetScopeDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
CONVERT_NUMBER_CHECKED(int, index, Int32, args[2]);
@@ -8628,7 +8777,7 @@
}
-static Object* Runtime_DebugPrintScopes(Arguments args) {
+static MaybeObject* Runtime_DebugPrintScopes(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 0);
@@ -8644,60 +8793,21 @@
}
-static Object* Runtime_GetCFrames(Arguments args) {
- HandleScope scope;
- ASSERT(args.length() == 1);
- Object* result = Runtime_CheckExecutionState(args);
- if (result->IsFailure()) return result;
-
-#if V8_HOST_ARCH_64_BIT
- UNIMPLEMENTED();
+static MaybeObject* Runtime_GetCFrames(Arguments args) {
+ // See bug 906.
return Heap::undefined_value();
-#else
-
- static const int kMaxCFramesSize = 200;
- ScopedVector<OS::StackFrame> frames(kMaxCFramesSize);
- int frames_count = OS::StackWalk(frames);
- if (frames_count == OS::kStackWalkError) {
- return Heap::undefined_value();
- }
-
- Handle<String> address_str = Factory::LookupAsciiSymbol("address");
- Handle<String> text_str = Factory::LookupAsciiSymbol("text");
- Handle<FixedArray> frames_array = Factory::NewFixedArray(frames_count);
- for (int i = 0; i < frames_count; i++) {
- Handle<JSObject> frame_value = Factory::NewJSObject(Top::object_function());
- Handle<Object> frame_address =
- Factory::NewNumberFromInt(reinterpret_cast<int>(frames[i].address));
-
- frame_value->SetProperty(*address_str, *frame_address, NONE);
-
- // Get the stack walk text for this frame.
- Handle<String> frame_text;
- int frame_text_length = StrLength(frames[i].text);
- if (frame_text_length > 0) {
- Vector<const char> str(frames[i].text, frame_text_length);
- frame_text = Factory::NewStringFromAscii(str);
- }
-
- if (!frame_text.is_null()) {
- frame_value->SetProperty(*text_str, *frame_text, NONE);
- }
-
- frames_array->set(i, *frame_value);
- }
- return *Factory::NewJSArrayWithElements(frames_array);
-#endif // V8_HOST_ARCH_64_BIT
}
-static Object* Runtime_GetThreadCount(Arguments args) {
+static MaybeObject* Runtime_GetThreadCount(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
// Check arguments.
- Object* result = Runtime_CheckExecutionState(args);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
// Count all archived V8 threads.
int n = 0;
@@ -8723,13 +8833,15 @@
// The array returned contains the following information:
// 0: Is current thread?
// 1: Thread id
-static Object* Runtime_GetThreadDetails(Arguments args) {
+static MaybeObject* Runtime_GetThreadDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
// Allocate array for result.
@@ -8765,7 +8877,7 @@
// Sets the disable break state
// args[0]: disable break state
-static Object* Runtime_SetDisableBreak(Arguments args) {
+static MaybeObject* Runtime_SetDisableBreak(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_BOOLEAN_CHECKED(disable_break, args[0]);
@@ -8774,7 +8886,7 @@
}
-static Object* Runtime_GetBreakLocations(Arguments args) {
+static MaybeObject* Runtime_GetBreakLocations(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -8793,7 +8905,7 @@
// args[0]: function
// args[1]: number: break source position (within the function source)
// args[2]: number: break point object
-static Object* Runtime_SetFunctionBreakPoint(Arguments args) {
+static MaybeObject* Runtime_SetFunctionBreakPoint(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSFunction, fun, 0);
@@ -8892,7 +9004,7 @@
// args[0]: script to set break point in
// args[1]: number: break source position (within the script source)
// args[2]: number: break point object
-static Object* Runtime_SetScriptBreakPoint(Arguments args) {
+static MaybeObject* Runtime_SetScriptBreakPoint(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSValue, wrapper, 0);
@@ -8926,7 +9038,7 @@
// Clear a break point
// args[0]: number: break point object
-static Object* Runtime_ClearBreakPoint(Arguments args) {
+static MaybeObject* Runtime_ClearBreakPoint(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
Handle<Object> break_point_object_arg = args.at<Object>(0);
@@ -8941,7 +9053,7 @@
// Change the state of break on exceptions.
// args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
// args[1]: Boolean indicating on/off.
-static Object* Runtime_ChangeBreakOnException(Arguments args) {
+static MaybeObject* Runtime_ChangeBreakOnException(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
RUNTIME_ASSERT(args[0]->IsNumber());
@@ -8959,7 +9071,7 @@
// Returns the state of break on exceptions
// args[0]: boolean indicating uncaught exceptions
-static Object* Runtime_IsBreakOnException(Arguments args) {
+static MaybeObject* Runtime_IsBreakOnException(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
RUNTIME_ASSERT(args[0]->IsNumber());
@@ -8976,12 +9088,14 @@
// args[1]: step action from the enumeration StepAction
// args[2]: number of times to perform the step, for step out it is the number
// of frames to step down.
-static Object* Runtime_PrepareStep(Arguments args) {
+static MaybeObject* Runtime_PrepareStep(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
return Top::Throw(Heap::illegal_argument_symbol());
}
@@ -9012,7 +9126,7 @@
// Clear all stepping set by PrepareStep.
-static Object* Runtime_ClearStepping(Arguments args) {
+static MaybeObject* Runtime_ClearStepping(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 0);
Debug::ClearStepping();
@@ -9089,14 +9203,18 @@
// stack frame presenting the same view of the values of parameters and
// local variables as if the piece of JavaScript was evaluated at the point
// where the function on the stack frame is currently stopped.
-static Object* Runtime_DebugEvaluate(Arguments args) {
+static MaybeObject* Runtime_DebugEvaluate(Arguments args) {
HandleScope scope;
// Check the execution state and decode arguments frame and source to be
// evaluated.
ASSERT(args.length() == 4);
- Object* check_result = Runtime_CheckExecutionState(args);
- if (check_result->IsFailure()) return check_result;
+ Object* check_result;
+ { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
+ if (!maybe_check_result->ToObject(&check_result)) {
+ return maybe_check_result;
+ }
+ }
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
CONVERT_ARG_CHECKED(String, source, 2);
CONVERT_BOOLEAN_CHECKED(disable_break, args[3]);
@@ -9200,14 +9318,18 @@
}
-static Object* Runtime_DebugEvaluateGlobal(Arguments args) {
+static MaybeObject* Runtime_DebugEvaluateGlobal(Arguments args) {
HandleScope scope;
// Check the execution state and decode arguments frame and source to be
// evaluated.
ASSERT(args.length() == 3);
- Object* check_result = Runtime_CheckExecutionState(args);
- if (check_result->IsFailure()) return check_result;
+ Object* check_result;
+ { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
+ if (!maybe_check_result->ToObject(&check_result)) {
+ return maybe_check_result;
+ }
+ }
CONVERT_ARG_CHECKED(String, source, 1);
CONVERT_BOOLEAN_CHECKED(disable_break, args[2]);
@@ -9250,7 +9372,7 @@
}
-static Object* Runtime_DebugGetLoadedScripts(Arguments args) {
+static MaybeObject* Runtime_DebugGetLoadedScripts(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 0);
@@ -9350,7 +9472,7 @@
// args[0]: the object to find references to
// args[1]: constructor function for instances to exclude (Mirror)
// args[2]: the the maximum number of objects to return
-static Object* Runtime_DebugReferencedBy(Arguments args) {
+static MaybeObject* Runtime_DebugReferencedBy(Arguments args) {
ASSERT(args.length() == 3);
// First perform a full GC in order to avoid references from dead objects.
@@ -9376,8 +9498,10 @@
NULL, 0, arguments_function);
// Allocate an array to hold the result.
- Object* object = Heap::AllocateFixedArray(count);
- if (object->IsFailure()) return object;
+ Object* object;
+ { MaybeObject* maybe_object = Heap::AllocateFixedArray(count);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
FixedArray* instances = FixedArray::cast(object);
// Fill the referencing objects.
@@ -9385,10 +9509,12 @@
instances, count, arguments_function);
// Return result as JS array.
- Object* result =
- Heap::AllocateJSObject(
- Top::context()->global_context()->array_function());
- if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateJSObject(
+ Top::context()->global_context()->array_function());
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
+ JSArray::cast(result)->SetContent(instances);
return result;
}
@@ -9426,7 +9552,7 @@
// Scan the heap for objects constructed by a specific function.
// args[0]: the constructor to find instances of
// args[1]: the the maximum number of objects to return
-static Object* Runtime_DebugConstructedBy(Arguments args) {
+static MaybeObject* Runtime_DebugConstructedBy(Arguments args) {
ASSERT(args.length() == 2);
// First perform a full GC in order to avoid dead objects.
@@ -9442,25 +9568,29 @@
count = DebugConstructedBy(constructor, max_references, NULL, 0);
// Allocate an array to hold the result.
- Object* object = Heap::AllocateFixedArray(count);
- if (object->IsFailure()) return object;
+ Object* object;
+ { MaybeObject* maybe_object = Heap::AllocateFixedArray(count);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
FixedArray* instances = FixedArray::cast(object);
// Fill the referencing objects.
count = DebugConstructedBy(constructor, max_references, instances, count);
// Return result as JS array.
- Object* result =
- Heap::AllocateJSObject(
- Top::context()->global_context()->array_function());
- if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateJSObject(
+ Top::context()->global_context()->array_function());
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
+ JSArray::cast(result)->SetContent(instances);
return result;
}
// Find the effective prototype object as returned by __proto__.
// args[0]: the object to find the prototype for.
-static Object* Runtime_DebugGetPrototype(Arguments args) {
+static MaybeObject* Runtime_DebugGetPrototype(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, obj, args[0]);
@@ -9470,14 +9600,14 @@
}
-static Object* Runtime_SystemBreak(Arguments args) {
+static MaybeObject* Runtime_SystemBreak(Arguments args) {
ASSERT(args.length() == 0);
CPU::DebugBreak();
return Heap::undefined_value();
}
-static Object* Runtime_DebugDisassembleFunction(Arguments args) {
+static MaybeObject* Runtime_DebugDisassembleFunction(Arguments args) {
#ifdef DEBUG
HandleScope scope;
ASSERT(args.length() == 1);
@@ -9493,7 +9623,7 @@
}
-static Object* Runtime_DebugDisassembleConstructor(Arguments args) {
+static MaybeObject* Runtime_DebugDisassembleConstructor(Arguments args) {
#ifdef DEBUG
HandleScope scope;
ASSERT(args.length() == 1);
@@ -9509,7 +9639,7 @@
}
-static Object* Runtime_FunctionGetInferredName(Arguments args) {
+static MaybeObject* Runtime_FunctionGetInferredName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -9545,7 +9675,7 @@
// For a script finds all SharedFunctionInfo's in the heap that points
// to this script. Returns JSArray of SharedFunctionInfo wrapped
// in OpaqueReferences.
-static Object* Runtime_LiveEditFindSharedFunctionInfosForScript(
+static MaybeObject* Runtime_LiveEditFindSharedFunctionInfosForScript(
Arguments args) {
ASSERT(args.length() == 1);
HandleScope scope;
@@ -9578,7 +9708,7 @@
// Returns a JSArray of compilation infos. The array is ordered so that
// each function with all its descendant is always stored in a continues range
// with the function itself going first. The root function is a script function.
-static Object* Runtime_LiveEditGatherCompileInfo(Arguments args) {
+static MaybeObject* Runtime_LiveEditGatherCompileInfo(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_CHECKED(JSValue, script, args[0]);
@@ -9597,7 +9727,7 @@
// Changes the source of the script to a new_source.
// If old_script_name is provided (i.e. is a String), also creates a copy of
// the script with its original source and sends notification to debugger.
-static Object* Runtime_LiveEditReplaceScript(Arguments args) {
+static MaybeObject* Runtime_LiveEditReplaceScript(Arguments args) {
ASSERT(args.length() == 3);
HandleScope scope;
CONVERT_CHECKED(JSValue, original_script_value, args[0]);
@@ -9621,7 +9751,7 @@
}
// Replaces code of SharedFunctionInfo with a new one.
-static Object* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
+static MaybeObject* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0);
@@ -9631,7 +9761,7 @@
}
// Connects SharedFunctionInfo to another script.
-static Object* Runtime_LiveEditFunctionSetScript(Arguments args) {
+static MaybeObject* Runtime_LiveEditFunctionSetScript(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
Handle<Object> function_object(args[0]);
@@ -9656,7 +9786,7 @@
// In a code of a parent function replaces original function as embedded object
// with a substitution one.
-static Object* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) {
+static MaybeObject* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) {
ASSERT(args.length() == 3);
HandleScope scope;
@@ -9676,7 +9806,7 @@
// array of groups of 3 numbers:
// (change_begin, change_end, change_end_new_position).
// Each group describes a change in text; groups are sorted by change_begin.
-static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
+static MaybeObject* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
@@ -9690,7 +9820,7 @@
// checks that none of them have activations on stacks (of any thread).
// Returns array of the same length with corresponding results of
// LiveEdit::FunctionPatchabilityStatus type.
-static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
+static MaybeObject* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
@@ -9701,7 +9831,7 @@
// Compares 2 strings line-by-line and returns diff in form of JSArray of
// triplets (pos1, pos1_end, pos2_end) describing list of diff chunks.
-static Object* Runtime_LiveEditCompareStringsLinewise(Arguments args) {
+static MaybeObject* Runtime_LiveEditCompareStringsLinewise(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(String, s1, 0);
@@ -9714,7 +9844,7 @@
// A testing entry. Returns statement position which is the closest to
// source_position.
-static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) {
+static MaybeObject* Runtime_GetFunctionCodePositionFromSource(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -9746,7 +9876,7 @@
// Calls specified function with or without entering the debugger.
// This is used in unit tests to run code as if debugger is entered or simply
// to have a stack with C++ frame in the middle.
-static Object* Runtime_ExecuteInDebugContext(Arguments args) {
+static MaybeObject* Runtime_ExecuteInDebugContext(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -9776,7 +9906,7 @@
#ifdef ENABLE_LOGGING_AND_PROFILING
-static Object* Runtime_ProfilerResume(Arguments args) {
+static MaybeObject* Runtime_ProfilerResume(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -9787,7 +9917,7 @@
}
-static Object* Runtime_ProfilerPause(Arguments args) {
+static MaybeObject* Runtime_ProfilerPause(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -9834,7 +9964,7 @@
// Get the script object from script data. NOTE: Regarding performance
// see the NOTE for GetScriptFromScriptData.
// args[0]: script data for the script to find the source for
-static Object* Runtime_GetScript(Arguments args) {
+static MaybeObject* Runtime_GetScript(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -9879,7 +10009,7 @@
// Collect the raw data for a stack trace. Returns an array of three
// element segments each containing a receiver, function and native
// code offset.
-static Object* Runtime_CollectStackTrace(Arguments args) {
+static MaybeObject* Runtime_CollectStackTrace(Arguments args) {
ASSERT_EQ(args.length(), 2);
Handle<Object> caller = args.at<Object>(0);
CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]);
@@ -9929,7 +10059,7 @@
// Returns V8 version as a string.
-static Object* Runtime_GetV8Version(Arguments args) {
+static MaybeObject* Runtime_GetV8Version(Arguments args) {
ASSERT_EQ(args.length(), 0);
NoHandleAllocation ha;
@@ -9940,7 +10070,7 @@
}
-static Object* Runtime_Abort(Arguments args) {
+static MaybeObject* Runtime_Abort(Arguments args) {
ASSERT(args.length() == 2);
OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) +
Smi::cast(args[1])->value());
@@ -9951,7 +10081,9 @@
}
-static Object* CacheMiss(FixedArray* cache_obj, int index, Object* key_obj) {
+MUST_USE_RESULT static MaybeObject* CacheMiss(FixedArray* cache_obj,
+ int index,
+ Object* key_obj) {
ASSERT(index % 2 == 0); // index of the key
ASSERT(index >= JSFunctionResultCache::kEntriesIndex);
ASSERT(index < cache_obj->length());
@@ -9986,7 +10118,7 @@
}
-static Object* Runtime_GetFromCache(Arguments args) {
+static MaybeObject* Runtime_GetFromCache(Arguments args) {
// This is only called from codegen, so checks might be more lax.
CONVERT_CHECKED(FixedArray, cache, args[0]);
Object* key = args[1];
@@ -10039,7 +10171,7 @@
#ifdef DEBUG
// ListNatives is ONLY used by the fuzz-natives.js in debug mode
// Exclude the code in release mode.
-static Object* Runtime_ListNatives(Arguments args) {
+static MaybeObject* Runtime_ListNatives(Arguments args) {
ASSERT(args.length() == 0);
HandleScope scope;
Handle<JSArray> result = Factory::NewJSArray(0);
@@ -10073,7 +10205,7 @@
#endif
-static Object* Runtime_Log(Arguments args) {
+static MaybeObject* Runtime_Log(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, format, args[0]);
CONVERT_CHECKED(JSArray, elms, args[1]);
@@ -10083,7 +10215,7 @@
}
-static Object* Runtime_IS_VAR(Arguments args) {
+static MaybeObject* Runtime_IS_VAR(Arguments args) {
UNREACHABLE(); // implemented as macro in the parser
return NULL;
}
@@ -10108,18 +10240,26 @@
};
-Object* Runtime::InitializeIntrinsicFunctionNames(Object* dictionary) {
+MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Object* dictionary) {
ASSERT(dictionary != NULL);
ASSERT(StringDictionary::cast(dictionary)->NumberOfElements() == 0);
for (int i = 0; i < kNumFunctions; ++i) {
- Object* name_symbol = Heap::LookupAsciiSymbol(kIntrinsicFunctions[i].name);
- if (name_symbol->IsFailure()) return name_symbol;
+ Object* name_symbol;
+ { MaybeObject* maybe_name_symbol =
+ Heap::LookupAsciiSymbol(kIntrinsicFunctions[i].name);
+ if (!maybe_name_symbol->ToObject(&name_symbol)) return maybe_name_symbol;
+ }
StringDictionary* string_dictionary = StringDictionary::cast(dictionary);
- dictionary = string_dictionary->Add(String::cast(name_symbol),
- Smi::FromInt(i),
- PropertyDetails(NONE, NORMAL));
- // Non-recoverable failure. Calling code must restart heap initialization.
- if (dictionary->IsFailure()) return dictionary;
+ { MaybeObject* maybe_dictionary = string_dictionary->Add(
+ String::cast(name_symbol),
+ Smi::FromInt(i),
+ PropertyDetails(NONE, NORMAL));
+ if (!maybe_dictionary->ToObject(&dictionary)) {
+ // Non-recoverable failure. Calling code must restart heap
+ // initialization.
+ return maybe_dictionary;
+ }
+ }
}
return dictionary;
}
« no previous file with comments | « src/runtime.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698