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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 isolate, value, 263 isolate, value,
264 CreateLiteralBoilerplate(isolate, literals, array), 264 CreateLiteralBoilerplate(isolate, literals, array),
265 Object); 265 Object);
266 } 266 }
267 MaybeHandle<Object> maybe_result; 267 MaybeHandle<Object> maybe_result;
268 uint32_t element_index = 0; 268 uint32_t element_index = 0;
269 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; 269 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT;
270 if (key->IsInternalizedString()) { 270 if (key->IsInternalizedString()) {
271 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 271 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
272 // Array index as string (uint32). 272 // Array index as string (uint32).
273 if (value->IsUninitialized()) { 273 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
274 maybe_result = value; 274 maybe_result =
275 } else { 275 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
276 maybe_result = JSObject::SetOwnElement(
277 boilerplate, element_index, value, SLOPPY);
278 }
279 } else { 276 } else {
280 Handle<String> name(String::cast(*key)); 277 Handle<String> name(String::cast(*key));
281 ASSERT(!name->AsArrayIndex(&element_index)); 278 ASSERT(!name->AsArrayIndex(&element_index));
282 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( 279 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
283 boilerplate, name, value, NONE, mode); 280 boilerplate, name, value, NONE, mode);
284 } 281 }
285 } else if (key->ToArrayIndex(&element_index)) { 282 } else if (key->ToArrayIndex(&element_index)) {
286 // Array index (uint32). 283 // Array index (uint32).
287 if (value->IsUninitialized()) { 284 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
288 maybe_result = value; 285 maybe_result =
289 } else { 286 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
290 maybe_result = JSObject::SetOwnElement(
291 boilerplate, element_index, value, SLOPPY);
292 }
293 } else { 287 } else {
294 // Non-uint32 number. 288 // Non-uint32 number.
295 ASSERT(key->IsNumber()); 289 ASSERT(key->IsNumber());
296 double num = key->Number(); 290 double num = key->Number();
297 char arr[100]; 291 char arr[100];
298 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 292 Vector<char> buffer(arr, ARRAY_SIZE(arr));
299 const char* str = DoubleToCString(num, buffer); 293 const char* str = DoubleToCString(num, buffer);
300 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); 294 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
301 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( 295 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
302 boilerplate, name, value, NONE, mode); 296 boilerplate, name, value, NONE, mode);
(...skipping 5020 matching lines...) Expand 10 before | Expand all | Expand 10 after
5323 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 5317 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5324 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); 5318 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
5325 RUNTIME_ASSERT( 5319 RUNTIME_ASSERT(
5326 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 5320 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5327 // Compute attributes. 5321 // Compute attributes.
5328 PropertyAttributes attributes = 5322 PropertyAttributes attributes =
5329 static_cast<PropertyAttributes>(unchecked_attributes); 5323 static_cast<PropertyAttributes>(unchecked_attributes);
5330 5324
5331 #ifdef DEBUG 5325 #ifdef DEBUG
5332 bool duplicate; 5326 bool duplicate;
5333 if (key->IsName()) { 5327 uint32_t index = 0;
5328 if (key->IsName() || !key->ToArrayIndex(&index)) {
5329 if (key->IsNumber()) {
5330 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
5331 Execution::ToString(isolate, key));
5332 }
5334 LookupIterator it(object, Handle<Name>::cast(key), 5333 LookupIterator it(object, Handle<Name>::cast(key),
5335 LookupIterator::CHECK_OWN_REAL); 5334 LookupIterator::CHECK_OWN_REAL);
5336 JSReceiver::GetPropertyAttributes(&it); 5335 JSReceiver::GetPropertyAttributes(&it);
5337 duplicate = it.IsFound(); 5336 duplicate = it.IsFound();
5338 } else { 5337 } else {
5339 uint32_t index = 0;
5340 RUNTIME_ASSERT(key->ToArrayIndex(&index));
5341 duplicate = JSReceiver::HasOwnElement(object, index); 5338 duplicate = JSReceiver::HasOwnElement(object, index);
5342 } 5339 }
5343 RUNTIME_ASSERT(!duplicate); 5340 RUNTIME_ASSERT(!duplicate);
5344 #endif 5341 #endif
5345 5342
5346 Handle<Object> result; 5343 Handle<Object> result;
5347 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5344 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5348 isolate, result, 5345 isolate, result,
5349 Runtime::DefineObjectProperty(object, key, value, attributes)); 5346 Runtime::DefineObjectProperty(object, key, value, attributes));
5350 return *result; 5347 return *result;
(...skipping 9757 matching lines...) Expand 10 before | Expand all | Expand 10 after
15108 } 15105 }
15109 return NULL; 15106 return NULL;
15110 } 15107 }
15111 15108
15112 15109
15113 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15110 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15114 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15111 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15115 } 15112 }
15116 15113
15117 } } // namespace v8::internal 15114 } } // namespace v8::internal
OLDNEW
« 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