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

Unified Diff: src/runtime.cc

Issue 231103002: Object::GetElements() and friends maybehandlification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: FixedArray::UnionOfKeys() maybehandlified Created 6 years, 8 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/stub-cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 3148327b6775ee0107de7f4d11d4708dd3f29759..f2e2650ce7d9e7c7c5a6d1c266a8ffead5f8e24a 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -637,14 +637,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) {
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
Handle<JSObject> registry = isolate->GetSymbolRegistry();
Handle<String> part = isolate->factory()->private_intern_string();
- Handle<JSObject> privates =
- Handle<JSObject>::cast(Object::GetPropertyOrElement(registry, part));
- Handle<Object> symbol = Object::GetPropertyOrElement(privates, name);
+ Handle<Object> privates;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, privates, Object::GetPropertyOrElement(registry, part));
+ Handle<Object> symbol;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, symbol, Object::GetPropertyOrElement(privates, name));
if (!symbol->IsSymbol()) {
ASSERT(symbol->IsUndefined());
symbol = isolate->factory()->NewPrivateSymbol();
Handle<Symbol>::cast(symbol)->set_name(*name);
- JSObject::SetProperty(privates, name, symbol, NONE, STRICT).Assert();
+ JSObject::SetProperty(Handle<JSObject>::cast(privates),
+ name, symbol, NONE, STRICT).Assert();
}
return *symbol;
}
@@ -1907,9 +1911,10 @@ enum PropertyDescriptorIndices {
};
-static Handle<Object> GetOwnProperty(Isolate* isolate,
- Handle<JSObject> obj,
- Handle<Name> name) {
+MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(
+ Isolate* isolate,
+ Handle<JSObject> obj,
+ Handle<Name> name) {
Heap* heap = isolate->heap();
Factory* factory = isolate->factory();
// Due to some WebKit tests, we want to make sure that we do not log
@@ -1940,8 +1945,10 @@ static Handle<Object> GetOwnProperty(Isolate* isolate,
if (!has_accessors) {
elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0));
// Runtime::GetObjectProperty does access check.
- Handle<Object> value = Runtime::GetObjectProperty(isolate, obj, name);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<Object>::null());
+ Handle<Object> value;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value, Runtime::GetObjectProperty(isolate, obj, name),
+ Object);
elms->set(VALUE_INDEX, *value);
} else {
// Access checks are performed for both accessors separately.
@@ -1953,14 +1960,14 @@ static Handle<Object> GetOwnProperty(Isolate* isolate,
ASSERT(!isolate->has_scheduled_exception());
elms->set(GETTER_INDEX, *getter);
} else {
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
}
if (!setter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_SET)) {
ASSERT(!isolate->has_scheduled_exception());
elms->set(SETTER_INDEX, *setter);
} else {
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
}
}
@@ -1980,8 +1987,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) {
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
- Handle<Object> result = GetOwnProperty(isolate, obj, name);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, GetOwnProperty(isolate, obj, name));
return *result;
}
@@ -4880,9 +4888,9 @@ static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
}
-Handle<Object> Runtime::GetElementOrCharAt(Isolate* isolate,
- Handle<Object> object,
- uint32_t index) {
+MaybeHandle<Object> Runtime::GetElementOrCharAt(Isolate* isolate,
+ Handle<Object> object,
+ uint32_t index) {
// Handle [] indexing on Strings
if (object->IsString()) {
Handle<Object> result = GetCharAt(Handle<String>::cast(object), index);
@@ -4937,9 +4945,9 @@ MaybeHandle<Object> Runtime::HasObjectProperty(Isolate* isolate,
}
-Handle<Object> Runtime::GetObjectProperty(Isolate* isolate,
- Handle<Object> object,
- Handle<Object> key) {
+MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
+ Handle<Object> object,
+ Handle<Object> key) {
if (object->IsUndefined() || object->IsNull()) {
Handle<Object> args[2] = { key, object };
isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load",
@@ -4973,8 +4981,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) {
Handle<Object> object = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
- Handle<Object> result = Runtime::GetObjectProperty(isolate, object, key);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::GetObjectProperty(isolate, object, key));
return *result;
}
@@ -5076,9 +5086,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) {
// Fall back to GetObjectProperty.
HandleScope scope(isolate);
- Handle<Object> result = Runtime::GetObjectProperty(
- isolate, args.at<Object>(0), args.at<Object>(1));
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::GetObjectProperty(
+ isolate, args.at<Object>(0), args.at<Object>(1)));
return *result;
}
@@ -5745,9 +5757,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
- bool threw = false;
- Handle<JSArray> result = GetKeysFor(object, &threw);
- if (threw) return Failure::Exception();
+ Handle<JSArray> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, GetKeysFor(object));
return *result;
}
@@ -5767,10 +5778,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) {
HandleScope scope(isolate);
Handle<JSReceiver> object(raw_object);
- bool threw = false;
- Handle<FixedArray> content =
- GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw);
- if (threw) return Failure::Exception();
+ Handle<FixedArray> content;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, content, GetKeysInFixedArrayFor(object, INCLUDE_PROTOS));
// Test again, since cache may have been built by preceding call.
if (object->IsSimpleEnum()) return object->map();
@@ -5999,10 +6009,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) {
object = Handle<JSObject>::cast(proto);
}
- bool threw = false;
- Handle<FixedArray> contents =
- GetKeysInFixedArrayFor(object, LOCAL_ONLY, &threw);
- if (threw) return Failure::Exception();
+ Handle<FixedArray> contents;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, contents, GetKeysInFixedArrayFor(object, LOCAL_ONLY));
// Some fast paths through GetKeysInFixedArrayFor reuse a cached
// property array and since the result is mutable we have to create
@@ -6067,9 +6076,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
return frame->GetParameter(index);
} else {
Handle<Object> initial_prototype(isolate->initial_object_prototype());
- Handle<Object> result =
- Object::GetElement(isolate, initial_prototype, index);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Object::GetElement(isolate, initial_prototype, index));
return *result;
}
}
@@ -8929,8 +8939,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) {
}
for (int i = 0; i < argc; ++i) {
- argv[i] = Object::GetElement(isolate, arguments, offset + i);
- RETURN_IF_EMPTY_HANDLE(isolate, argv[i]);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, argv[i],
+ Object::GetElement(isolate, arguments, offset + i));
}
bool threw;
@@ -10280,8 +10291,10 @@ static bool IterateElements(Isolate* isolate,
} else if (JSReceiver::HasElement(receiver, j)) {
// Call GetElement on receiver, not its prototype, or getters won't
// have the correct receiver.
- element_value = Object::GetElement(isolate, receiver, j);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, element_value,
+ Object::GetElement(isolate, receiver, j),
+ false);
visitor->visit(j, element_value);
}
}
@@ -10305,9 +10318,11 @@ static bool IterateElements(Isolate* isolate,
} else if (JSReceiver::HasElement(receiver, j)) {
// Call GetElement on receiver, not its prototype, or getters won't
// have the correct receiver.
- Handle<Object> element_value =
- Object::GetElement(isolate, receiver, j);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
+ Handle<Object> element_value;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, element_value,
+ Object::GetElement(isolate, receiver, j),
+ false);
visitor->visit(j, element_value);
}
}
@@ -10325,8 +10340,11 @@ static bool IterateElements(Isolate* isolate,
while (j < n) {
HandleScope loop_scope(isolate);
uint32_t index = indices[j];
- Handle<Object> element = Object::GetElement(isolate, receiver, index);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false);
+ Handle<Object> element;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, element,
+ Object::GetElement(isolate, receiver, index),
+ false);
visitor->visit(index, element);
// Skip to next different index (i.e., omit duplicates).
do {
@@ -10669,7 +10687,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
isolate->factory()->NewFixedArray(
current->NumberOfLocalElements(NONE));
current->GetLocalElementKeys(*current_keys, NONE);
- keys = FixedArray::UnionOfKeys(keys, current_keys);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, keys, FixedArray::UnionOfKeys(keys, current_keys));
}
// Erase any keys >= length.
// TODO(adamk): Remove this step when the contract of %GetArrayKeys
@@ -10851,9 +10870,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) {
uint32_t index;
if (name->AsArrayIndex(&index)) {
Handle<FixedArray> details = isolate->factory()->NewFixedArray(2);
- Handle<Object> element_or_char =
- Runtime::GetElementOrCharAt(isolate, obj, index);
- RETURN_IF_EMPTY_HANDLE(isolate, element_or_char);
+ Handle<Object> element_or_char;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, element_or_char,
+ Runtime::GetElementOrCharAt(isolate, obj, index));
details->set(0, *element_or_char);
details->set(
1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi());
@@ -10991,8 +11011,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
RUNTIME_ASSERT(obj->HasIndexedInterceptor());
CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]);
- Handle<Object> result = JSObject::GetElementWithInterceptor(obj, obj, index);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index));
return *result;
}
@@ -11482,7 +11503,8 @@ static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
ASSERT(!frame->GetParameter(i)->IsTheHole());
HandleScope scope(isolate);
Handle<String> name(scope_info->ParameterName(i));
- Handle<Object> value = Object::GetPropertyOrElement(target, name);
+ Handle<Object> value =
+ Object::GetPropertyOrElement(target, name).ToHandleChecked();
frame->SetParameterValue(i, *value);
}
@@ -11491,7 +11513,8 @@ static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
if (frame->GetExpression(i)->IsTheHole()) continue;
HandleScope scope(isolate);
Handle<Object> value = Object::GetPropertyOrElement(
- target, Handle<String>(scope_info->StackLocalName(i)));
+ target,
+ handle(scope_info->StackLocalName(i), isolate)).ToHandleChecked();
frame->SetExpression(i, *value);
}
}
@@ -11522,23 +11545,21 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext(
if (function_context->has_extension() &&
!function_context->IsNativeContext()) {
Handle<JSObject> ext(JSObject::cast(function_context->extension()));
- bool threw = false;
- Handle<FixedArray> keys =
- GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw);
- if (threw) return Handle<JSObject>();
+ Handle<FixedArray> keys;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, keys, GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS), JSObject);
for (int i = 0; i < keys->length(); i++) {
// Names of variables introduced by eval are strings.
ASSERT(keys->get(i)->IsString());
Handle<String> key(String::cast(keys->get(i)));
+ Handle<Object> value;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(isolate,
- target,
- key,
- Object::GetPropertyOrElement(ext, key),
- NONE,
- SLOPPY),
+ Runtime::SetObjectProperty(
+ isolate, target, key, value, NONE, SLOPPY),
JSObject);
}
}
@@ -11677,20 +11698,22 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure(
// be variables introduced by eval.
if (context->has_extension()) {
Handle<JSObject> ext(JSObject::cast(context->extension()));
- bool threw = false;
- Handle<FixedArray> keys =
- GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw);
- if (threw) return Handle<JSObject>();
+ Handle<FixedArray> keys;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, keys, GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS), JSObject);
for (int i = 0; i < keys->length(); i++) {
+ HandleScope scope(isolate);
// Names of variables introduced by eval are strings.
ASSERT(keys->get(i)->IsString());
Handle<String> key(String::cast(keys->get(i)));
- RETURN_ON_EXCEPTION(
+ Handle<Object> value;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
+ RETURN_ON_EXCEPTION(
isolate,
- Runtime::SetObjectProperty(isolate, closure_scope, key,
- Object::GetPropertyOrElement(ext, key),
- NONE, SLOPPY),
+ Runtime::SetObjectProperty(
+ isolate, closure_scope, key, value, NONE, SLOPPY),
JSObject);
}
}
@@ -13808,8 +13831,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) {
Handle<Name> base =
isolate->factory()->NewStringFromAscii(CStrVector("base"));
for (unsigned int i = 0; i < length; ++i) {
- Handle<Object> locale_id = Object::GetElement(isolate, input, i);
- RETURN_IF_EMPTY_HANDLE(isolate, locale_id);
+ Handle<Object> locale_id;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, locale_id, Object::GetElement(isolate, input, i));
if (!locale_id->IsString()) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
}
« no previous file with comments | « src/runtime.h ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698