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

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

Issue 1768203002: Properly prepare boilerplate properties in the parser for the runtime (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: drop IsInternalized DCHECK Created 4 years, 9 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/ast/ast.cc ('k') | no next file » | 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.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/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (value->IsFixedArray()) { 79 if (value->IsFixedArray()) {
80 // The value contains the constant_properties of a 80 // The value contains the constant_properties of a
81 // simple object or array literal. 81 // simple object or array literal.
82 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 82 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
83 ASSIGN_RETURN_ON_EXCEPTION( 83 ASSIGN_RETURN_ON_EXCEPTION(
84 isolate, value, CreateLiteralBoilerplate(isolate, literals, array), 84 isolate, value, CreateLiteralBoilerplate(isolate, literals, array),
85 Object); 85 Object);
86 } 86 }
87 MaybeHandle<Object> maybe_result; 87 MaybeHandle<Object> maybe_result;
88 uint32_t element_index = 0; 88 uint32_t element_index = 0;
89 if (key->IsInternalizedString()) { 89 if (key->ToArrayIndex(&element_index)) {
90 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
91 // Array index as string (uint32).
92 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
93 maybe_result = JSObject::SetOwnElementIgnoreAttributes(
94 boilerplate, element_index, value, NONE);
95 } else {
96 Handle<String> name(String::cast(*key));
97 DCHECK(!name->AsArrayIndex(&element_index));
98 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
99 boilerplate, name, value, NONE);
100 }
101 } else if (key->ToArrayIndex(&element_index)) {
102 // Array index (uint32). 90 // Array index (uint32).
103 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 91 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
104 maybe_result = JSObject::SetOwnElementIgnoreAttributes( 92 maybe_result = JSObject::SetOwnElementIgnoreAttributes(
105 boilerplate, element_index, value, NONE); 93 boilerplate, element_index, value, NONE);
106 } else { 94 } else {
107 // Non-uint32 number. 95 Handle<String> name = Handle<String>::cast(key);
108 DCHECK(key->IsNumber()); 96 DCHECK(!name->AsArrayIndex(&element_index));
109 double num = key->Number();
110 char arr[100];
111 Vector<char> buffer(arr, arraysize(arr));
112 const char* str = DoubleToCString(num, buffer);
113 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
114 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name, 97 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name,
115 value, NONE); 98 value, NONE);
116 } 99 }
117 // If setting the property on the boilerplate throws an
118 // exception, the exception is converted to an empty handle in
119 // the handle based operations. In that case, we need to
120 // convert back to an exception.
121 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); 100 RETURN_ON_EXCEPTION(isolate, maybe_result, Object);
122 } 101 }
123 102
124 // Transform to fast properties if necessary. For object literals with 103 // Transform to fast properties if necessary. For object literals with
125 // containing function literals we defer this operation until after all 104 // containing function literals we defer this operation until after all
126 // computed properties have been assigned so that we can generate 105 // computed properties have been assigned so that we can generate
127 // constant function properties. 106 // constant function properties.
128 if (should_transform && !has_function_literal) { 107 if (should_transform && !has_function_literal) {
129 JSObject::MigrateSlowToFast(boilerplate, 108 JSObject::MigrateSlowToFast(boilerplate,
130 boilerplate->map()->unused_property_fields(), 109 boilerplate->map()->unused_property_fields(),
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 Handle<LiteralsArray> literals(closure->literals(), isolate); 361 Handle<LiteralsArray> literals(closure->literals(), isolate);
383 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 362 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
384 isolate, result, 363 isolate, result,
385 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, 364 CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
386 ArrayLiteral::kShallowElements)); 365 ArrayLiteral::kShallowElements));
387 return *result; 366 return *result;
388 } 367 }
389 368
390 } // namespace internal 369 } // namespace internal
391 } // namespace v8 370 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698