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

Unified Diff: src/runtime.cc

Issue 371973002: Fix computed properties on object literals with a double as propertyname. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.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 893e31be5cd740e8d28192a4799c9cd59d614bf5..28481383a5fbd846a6940deb9a1b08ee64dab56e 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -270,12 +270,9 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
if (key->IsInternalizedString()) {
if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
// Array index as string (uint32).
- if (value->IsUninitialized()) {
- maybe_result = value;
- } else {
- maybe_result = JSObject::SetOwnElement(
- boilerplate, element_index, value, SLOPPY);
- }
+ if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
+ maybe_result =
+ JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
} else {
Handle<String> name(String::cast(*key));
ASSERT(!name->AsArrayIndex(&element_index));
@@ -284,12 +281,9 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
}
} else if (key->ToArrayIndex(&element_index)) {
// Array index (uint32).
- if (value->IsUninitialized()) {
- maybe_result = value;
- } else {
- maybe_result = JSObject::SetOwnElement(
- boilerplate, element_index, value, SLOPPY);
- }
+ if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
+ maybe_result =
+ JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
} else {
// Non-uint32 number.
ASSERT(key->IsNumber());
@@ -5330,14 +5324,17 @@ RUNTIME_FUNCTION(Runtime_AddProperty) {
#ifdef DEBUG
bool duplicate;
- if (key->IsName()) {
+ uint32_t index = 0;
+ if (key->IsName() || !key->ToArrayIndex(&index)) {
+ if (key->IsNumber()) {
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
+ Execution::ToString(isolate, key));
+ }
LookupIterator it(object, Handle<Name>::cast(key),
LookupIterator::CHECK_OWN_REAL);
JSReceiver::GetPropertyAttributes(&it);
duplicate = it.IsFound();
} else {
- uint32_t index = 0;
- RUNTIME_ASSERT(key->ToArrayIndex(&index));
duplicate = JSReceiver::HasOwnElement(object, index);
}
RUNTIME_ASSERT(!duplicate);
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698