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

Side by Side Diff: src/runtime/runtime-literals.cc

Issue 1172683003: Use the LookupIterator for SetElement and friends (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 6 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
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/runtime/runtime-object.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 isolate, value, 87 isolate, value,
88 CreateLiteralBoilerplate(isolate, literals, array, is_strong), 88 CreateLiteralBoilerplate(isolate, literals, array, is_strong),
89 Object); 89 Object);
90 } 90 }
91 MaybeHandle<Object> maybe_result; 91 MaybeHandle<Object> maybe_result;
92 uint32_t element_index = 0; 92 uint32_t element_index = 0;
93 if (key->IsInternalizedString()) { 93 if (key->IsInternalizedString()) {
94 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 94 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
95 // Array index as string (uint32). 95 // Array index as string (uint32).
96 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 96 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
97 maybe_result = 97 maybe_result = JSObject::SetOwnElementIgnoreAttributes(
98 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); 98 boilerplate, element_index, value, NONE);
99 } else { 99 } else {
100 Handle<String> name(String::cast(*key)); 100 Handle<String> name(String::cast(*key));
101 DCHECK(!name->AsArrayIndex(&element_index)); 101 DCHECK(!name->AsArrayIndex(&element_index));
102 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( 102 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
103 boilerplate, name, value, NONE); 103 boilerplate, name, value, NONE);
104 } 104 }
105 } else if (key->ToArrayIndex(&element_index)) { 105 } else if (key->ToArrayIndex(&element_index)) {
106 // Array index (uint32). 106 // Array index (uint32).
107 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 107 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
108 maybe_result = 108 maybe_result = JSObject::SetOwnElementIgnoreAttributes(
109 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); 109 boilerplate, element_index, value, NONE);
110 } else { 110 } else {
111 // Non-uint32 number. 111 // Non-uint32 number.
112 DCHECK(key->IsNumber()); 112 DCHECK(key->IsNumber());
113 double num = key->Number(); 113 double num = key->Number();
114 char arr[100]; 114 char arr[100];
115 Vector<char> buffer(arr, arraysize(arr)); 115 Vector<char> buffer(arr, arraysize(arr));
116 const char* str = DoubleToCString(num, buffer); 116 const char* str = DoubleToCString(num, buffer);
117 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); 117 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
118 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name, 118 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name,
119 value, NONE); 119 value, NONE);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); 430 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind);
431 } 431 }
432 } 432 }
433 FixedArray* object_array = FixedArray::cast(object->elements()); 433 FixedArray* object_array = FixedArray::cast(object->elements());
434 object_array->set(store_index, *value); 434 object_array->set(store_index, *value);
435 } 435 }
436 return *object; 436 return *object;
437 } 437 }
438 } // namespace internal 438 } // namespace internal
439 } // namespace v8 439 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698