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/runtime-literals.cc

Issue 1143813002: Reland "[strong] Object literals create strong objects" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix handlification bug Created 5 years, 7 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.h ('k') | test/mjsunit/strong/literals.js » ('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"
11 #include "src/runtime/runtime.h" 11 #include "src/runtime/runtime.h"
12 #include "src/runtime/runtime-utils.h" 12 #include "src/runtime/runtime-utils.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 static Handle<Map> ComputeObjectLiteralMap( 17 static Handle<Map> ComputeObjectLiteralMap(
18 Handle<Context> context, Handle<FixedArray> constant_properties, 18 Handle<Context> context, Handle<FixedArray> constant_properties,
19 bool* is_result_from_cache) { 19 bool is_strong, bool* is_result_from_cache) {
20 int properties_length = constant_properties->length(); 20 int properties_length = constant_properties->length();
21 int number_of_properties = properties_length / 2; 21 int number_of_properties = properties_length / 2;
22 22
23 for (int p = 0; p != properties_length; p += 2) { 23 for (int p = 0; p != properties_length; p += 2) {
24 Object* key = constant_properties->get(p); 24 Object* key = constant_properties->get(p);
25 uint32_t element_index = 0; 25 uint32_t element_index = 0;
26 if (key->ToArrayIndex(&element_index)) { 26 if (key->ToArrayIndex(&element_index)) {
27 // An index key does not require space in the property backing store. 27 // An index key does not require space in the property backing store.
28 number_of_properties--; 28 number_of_properties--;
29 } 29 }
30 } 30 }
31 Isolate* isolate = context->GetIsolate(); 31 Isolate* isolate = context->GetIsolate();
32 return isolate->factory()->ObjectLiteralMapFromCache( 32 return isolate->factory()->ObjectLiteralMapFromCache(
33 context, number_of_properties, is_result_from_cache); 33 context, number_of_properties, is_strong, is_result_from_cache);
34 } 34 }
35 35
36 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( 36 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
37 Isolate* isolate, Handle<FixedArray> literals, 37 Isolate* isolate, Handle<FixedArray> literals,
38 Handle<FixedArray> constant_properties); 38 Handle<FixedArray> constant_properties, bool is_strong);
39 39
40 40
41 MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( 41 MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
42 Isolate* isolate, Handle<FixedArray> literals, 42 Isolate* isolate, Handle<FixedArray> literals,
43 Handle<FixedArray> constant_properties, bool should_have_fast_elements, 43 Handle<FixedArray> constant_properties, bool should_have_fast_elements,
44 bool has_function_literal) { 44 bool has_function_literal, bool is_strong) {
45 Handle<Context> context = isolate->native_context(); 45 Handle<Context> context = isolate->native_context();
46 46
47 // In case we have function literals, we want the object to be in 47 // In case we have function literals, we want the object to be in
48 // slow properties mode for now. We don't go in the map cache because 48 // slow properties mode for now. We don't go in the map cache because
49 // maps with constant functions can't be shared if the functions are 49 // maps with constant functions can't be shared if the functions are
50 // not the same (which is the common case). 50 // not the same (which is the common case).
51 // TODO(rossberg): handle strong objects with function literals
51 bool is_result_from_cache = false; 52 bool is_result_from_cache = false;
52 Handle<Map> map = has_function_literal 53 Handle<Map> map = has_function_literal
53 ? Handle<Map>(context->object_function()->initial_map()) 54 ? Handle<Map>(context->object_function()->initial_map())
54 : ComputeObjectLiteralMap(context, constant_properties, 55 : ComputeObjectLiteralMap(context, constant_properties,
56 is_strong,
55 &is_result_from_cache); 57 &is_result_from_cache);
56 58
57 PretenureFlag pretenure_flag = 59 PretenureFlag pretenure_flag =
58 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; 60 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
59 61
60 Handle<JSObject> boilerplate = 62 Handle<JSObject> boilerplate =
61 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); 63 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag);
62 64
63 // Normalize the elements of the boilerplate to save space if needed. 65 // Normalize the elements of the boilerplate to save space if needed.
64 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); 66 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate);
(...skipping 10 matching lines...) Expand all
75 } 77 }
76 // TODO(verwaest): Support tracking representations in the boilerplate. 78 // TODO(verwaest): Support tracking representations in the boilerplate.
77 for (int index = 0; index < length; index += 2) { 79 for (int index = 0; index < length; index += 2) {
78 Handle<Object> key(constant_properties->get(index + 0), isolate); 80 Handle<Object> key(constant_properties->get(index + 0), isolate);
79 Handle<Object> value(constant_properties->get(index + 1), isolate); 81 Handle<Object> value(constant_properties->get(index + 1), isolate);
80 if (value->IsFixedArray()) { 82 if (value->IsFixedArray()) {
81 // The value contains the constant_properties of a 83 // The value contains the constant_properties of a
82 // simple object or array literal. 84 // simple object or array literal.
83 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 85 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
84 ASSIGN_RETURN_ON_EXCEPTION( 86 ASSIGN_RETURN_ON_EXCEPTION(
85 isolate, value, CreateLiteralBoilerplate(isolate, literals, array), 87 isolate, value,
88 CreateLiteralBoilerplate(isolate, literals, array, is_strong),
86 Object); 89 Object);
87 } 90 }
88 MaybeHandle<Object> maybe_result; 91 MaybeHandle<Object> maybe_result;
89 uint32_t element_index = 0; 92 uint32_t element_index = 0;
90 if (key->IsInternalizedString()) { 93 if (key->IsInternalizedString()) {
91 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 94 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
92 // Array index as string (uint32). 95 // Array index as string (uint32).
93 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 96 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
94 maybe_result = 97 maybe_result =
95 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); 98 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 JSObject::MigrateSlowToFast(boilerplate, 133 JSObject::MigrateSlowToFast(boilerplate,
131 boilerplate->map()->unused_property_fields(), 134 boilerplate->map()->unused_property_fields(),
132 "FastLiteral"); 135 "FastLiteral");
133 } 136 }
134 return boilerplate; 137 return boilerplate;
135 } 138 }
136 139
137 140
138 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( 141 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
139 Isolate* isolate, Handle<FixedArray> literals, 142 Isolate* isolate, Handle<FixedArray> literals,
140 Handle<FixedArray> elements) { 143 Handle<FixedArray> elements, bool is_strong) {
141 // Create the JSArray. 144 // Create the JSArray.
142 Handle<JSFunction> constructor = isolate->array_function(); 145 Handle<JSFunction> constructor = isolate->array_function();
143 146
144 PretenureFlag pretenure_flag = 147 PretenureFlag pretenure_flag =
145 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; 148 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
146 149
147 Handle<JSArray> object = Handle<JSArray>::cast( 150 Handle<JSArray> object = Handle<JSArray>::cast(
148 isolate->factory()->NewJSObject(constructor, pretenure_flag)); 151 isolate->factory()->NewJSObject(constructor, pretenure_flag));
149 152
150 ElementsKind constant_elements_kind = 153 ElementsKind constant_elements_kind =
151 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); 154 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value());
152 Handle<FixedArrayBase> constant_elements_values( 155 Handle<FixedArrayBase> constant_elements_values(
153 FixedArrayBase::cast(elements->get(1))); 156 FixedArrayBase::cast(elements->get(1)));
154 157
155 { 158 {
156 DisallowHeapAllocation no_gc; 159 DisallowHeapAllocation no_gc;
157 DCHECK(IsFastElementsKind(constant_elements_kind)); 160 DCHECK(IsFastElementsKind(constant_elements_kind));
158 Context* native_context = isolate->context()->native_context(); 161 Context* native_context = isolate->context()->native_context();
159 Object* maps_array = native_context->js_array_maps(); 162 Object* maps_array = is_strong
163 ? native_context->js_array_strong_maps()
164 : native_context->js_array_maps();
160 DCHECK(!maps_array->IsUndefined()); 165 DCHECK(!maps_array->IsUndefined());
161 Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind); 166 Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind);
162 object->set_map(Map::cast(map)); 167 object->set_map(Map::cast(map));
163 } 168 }
164 169
165 Handle<FixedArrayBase> copied_elements_values; 170 Handle<FixedArrayBase> copied_elements_values;
166 if (IsFastDoubleElementsKind(constant_elements_kind)) { 171 if (IsFastDoubleElementsKind(constant_elements_kind)) {
167 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( 172 copied_elements_values = isolate->factory()->CopyFixedDoubleArray(
168 Handle<FixedDoubleArray>::cast(constant_elements_values)); 173 Handle<FixedDoubleArray>::cast(constant_elements_values));
169 } else { 174 } else {
(...skipping 15 matching lines...) Expand all
185 Handle<FixedArray> fixed_array_values_copy = 190 Handle<FixedArray> fixed_array_values_copy =
186 isolate->factory()->CopyFixedArray(fixed_array_values); 191 isolate->factory()->CopyFixedArray(fixed_array_values);
187 copied_elements_values = fixed_array_values_copy; 192 copied_elements_values = fixed_array_values_copy;
188 for (int i = 0; i < fixed_array_values->length(); i++) { 193 for (int i = 0; i < fixed_array_values->length(); i++) {
189 if (fixed_array_values->get(i)->IsFixedArray()) { 194 if (fixed_array_values->get(i)->IsFixedArray()) {
190 // The value contains the constant_properties of a 195 // The value contains the constant_properties of a
191 // simple object or array literal. 196 // simple object or array literal.
192 Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i))); 197 Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i)));
193 Handle<Object> result; 198 Handle<Object> result;
194 ASSIGN_RETURN_ON_EXCEPTION( 199 ASSIGN_RETURN_ON_EXCEPTION(
195 isolate, result, CreateLiteralBoilerplate(isolate, literals, fa), 200 isolate, result,
201 CreateLiteralBoilerplate(isolate, literals, fa, is_strong),
196 Object); 202 Object);
197 fixed_array_values_copy->set(i, *result); 203 fixed_array_values_copy->set(i, *result);
198 } 204 }
199 } 205 }
200 } 206 }
201 } 207 }
202 object->set_elements(*copied_elements_values); 208 object->set_elements(*copied_elements_values);
203 object->set_length(Smi::FromInt(copied_elements_values->length())); 209 object->set_length(Smi::FromInt(copied_elements_values->length()));
204 210
205 JSObject::ValidateElements(object); 211 JSObject::ValidateElements(object);
206 return object; 212 return object;
207 } 213 }
208 214
209 215
210 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( 216 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
211 Isolate* isolate, Handle<FixedArray> literals, Handle<FixedArray> array) { 217 Isolate* isolate, Handle<FixedArray> literals, Handle<FixedArray> array,
218 bool is_strong) {
212 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); 219 Handle<FixedArray> elements = CompileTimeValue::GetElements(array);
213 const bool kHasNoFunctionLiteral = false; 220 const bool kHasNoFunctionLiteral = false;
214 switch (CompileTimeValue::GetLiteralType(array)) { 221 switch (CompileTimeValue::GetLiteralType(array)) {
215 case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS: 222 case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS:
216 return CreateObjectLiteralBoilerplate(isolate, literals, elements, true, 223 return CreateObjectLiteralBoilerplate(isolate, literals, elements, true,
217 kHasNoFunctionLiteral); 224 kHasNoFunctionLiteral, is_strong);
218 case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS: 225 case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
219 return CreateObjectLiteralBoilerplate(isolate, literals, elements, false, 226 return CreateObjectLiteralBoilerplate(isolate, literals, elements, false,
220 kHasNoFunctionLiteral); 227 kHasNoFunctionLiteral, is_strong);
221 case CompileTimeValue::ARRAY_LITERAL: 228 case CompileTimeValue::ARRAY_LITERAL:
222 return Runtime::CreateArrayLiteralBoilerplate(isolate, literals, 229 return Runtime::CreateArrayLiteralBoilerplate(isolate, literals,
223 elements); 230 elements, is_strong);
224 default: 231 default:
225 UNREACHABLE(); 232 UNREACHABLE();
226 return MaybeHandle<Object>(); 233 return MaybeHandle<Object>();
227 } 234 }
228 } 235 }
229 236
230 237
231 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { 238 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
232 HandleScope scope(isolate); 239 HandleScope scope(isolate);
233 DCHECK(args.length() == 4); 240 DCHECK(args.length() == 4);
234 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 241 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
235 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 242 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
236 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 243 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
237 CONVERT_SMI_ARG_CHECKED(flags, 3); 244 CONVERT_SMI_ARG_CHECKED(flags, 3);
238 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 245 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
239 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 246 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
240 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; 247 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0;
248 bool is_strong = (flags & ObjectLiteral::kIsStrong) != 0;
241 249
242 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); 250 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length());
243 251
244 // Check if boilerplate exists. If not, create it first. 252 // Check if boilerplate exists. If not, create it first.
245 Handle<Object> literal_site(literals->get(literals_index), isolate); 253 Handle<Object> literal_site(literals->get(literals_index), isolate);
246 Handle<AllocationSite> site; 254 Handle<AllocationSite> site;
247 Handle<JSObject> boilerplate; 255 Handle<JSObject> boilerplate;
248 if (*literal_site == isolate->heap()->undefined_value()) { 256 if (*literal_site == isolate->heap()->undefined_value()) {
249 Handle<Object> raw_boilerplate; 257 Handle<Object> raw_boilerplate;
250 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 258 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
251 isolate, raw_boilerplate, 259 isolate, raw_boilerplate,
252 CreateObjectLiteralBoilerplate(isolate, literals, constant_properties, 260 CreateObjectLiteralBoilerplate(isolate, literals, constant_properties,
253 should_have_fast_elements, 261 should_have_fast_elements,
254 has_function_literal)); 262 has_function_literal, is_strong));
255 boilerplate = Handle<JSObject>::cast(raw_boilerplate); 263 boilerplate = Handle<JSObject>::cast(raw_boilerplate);
256 264
257 AllocationSiteCreationContext creation_context(isolate); 265 AllocationSiteCreationContext creation_context(isolate);
258 site = creation_context.EnterNewScope(); 266 site = creation_context.EnterNewScope();
259 RETURN_FAILURE_ON_EXCEPTION( 267 RETURN_FAILURE_ON_EXCEPTION(
260 isolate, JSObject::DeepWalk(boilerplate, &creation_context)); 268 isolate, JSObject::DeepWalk(boilerplate, &creation_context));
261 creation_context.ExitScope(site, boilerplate); 269 creation_context.ExitScope(site, boilerplate);
262 270
263 // Update the functions literal and return the boilerplate. 271 // Update the functions literal and return the boilerplate.
264 literals->set(literals_index, *site); 272 literals->set(literals_index, *site);
265 } else { 273 } else {
266 site = Handle<AllocationSite>::cast(literal_site); 274 site = Handle<AllocationSite>::cast(literal_site);
267 boilerplate = 275 boilerplate =
268 Handle<JSObject>(JSObject::cast(site->transition_info()), isolate); 276 Handle<JSObject>(JSObject::cast(site->transition_info()), isolate);
269 } 277 }
270 278
271 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); 279 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
272 usage_context.EnterNewScope(); 280 usage_context.EnterNewScope();
273 MaybeHandle<Object> maybe_copy = 281 MaybeHandle<Object> maybe_copy =
274 JSObject::DeepCopy(boilerplate, &usage_context); 282 JSObject::DeepCopy(boilerplate, &usage_context);
275 usage_context.ExitScope(site, boilerplate); 283 usage_context.ExitScope(site, boilerplate);
276 Handle<Object> copy; 284 Handle<Object> copy;
277 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy); 285 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy);
278 return *copy; 286 return *copy;
279 } 287 }
280 288
281 289
282 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( 290 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
283 Isolate* isolate, Handle<FixedArray> literals, int literals_index, 291 Isolate* isolate, Handle<FixedArray> literals, int literals_index,
284 Handle<FixedArray> elements) { 292 Handle<FixedArray> elements, bool is_strong) {
285 // Check if boilerplate exists. If not, create it first. 293 // Check if boilerplate exists. If not, create it first.
286 Handle<Object> literal_site(literals->get(literals_index), isolate); 294 Handle<Object> literal_site(literals->get(literals_index), isolate);
287 Handle<AllocationSite> site; 295 Handle<AllocationSite> site;
288 if (*literal_site == isolate->heap()->undefined_value()) { 296 if (*literal_site == isolate->heap()->undefined_value()) {
289 DCHECK(*elements != isolate->heap()->empty_fixed_array()); 297 DCHECK(*elements != isolate->heap()->empty_fixed_array());
290 Handle<Object> boilerplate; 298 Handle<Object> boilerplate;
291 ASSIGN_RETURN_ON_EXCEPTION( 299 ASSIGN_RETURN_ON_EXCEPTION(
292 isolate, boilerplate, 300 isolate, boilerplate,
293 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements), 301 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements,
302 is_strong),
294 AllocationSite); 303 AllocationSite);
295 304
296 AllocationSiteCreationContext creation_context(isolate); 305 AllocationSiteCreationContext creation_context(isolate);
297 site = creation_context.EnterNewScope(); 306 site = creation_context.EnterNewScope();
298 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), 307 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate),
299 &creation_context).is_null()) { 308 &creation_context).is_null()) {
300 return Handle<AllocationSite>::null(); 309 return Handle<AllocationSite>::null();
301 } 310 }
302 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate)); 311 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate));
303 312
304 literals->set(literals_index, *site); 313 literals->set(literals_index, *site);
305 } else { 314 } else {
306 site = Handle<AllocationSite>::cast(literal_site); 315 site = Handle<AllocationSite>::cast(literal_site);
307 } 316 }
308 317
309 return site; 318 return site;
310 } 319 }
311 320
312 321
313 static MaybeHandle<JSObject> CreateArrayLiteralImpl(Isolate* isolate, 322 static MaybeHandle<JSObject> CreateArrayLiteralImpl(Isolate* isolate,
314 Handle<FixedArray> literals, 323 Handle<FixedArray> literals,
315 int literals_index, 324 int literals_index,
316 Handle<FixedArray> elements, 325 Handle<FixedArray> elements,
317 int flags) { 326 int flags) {
318 RUNTIME_ASSERT_HANDLIFIED( 327 RUNTIME_ASSERT_HANDLIFIED(
319 literals_index >= 0 && literals_index < literals->length(), JSObject); 328 literals_index >= 0 && literals_index < literals->length(), JSObject);
320 Handle<AllocationSite> site; 329 Handle<AllocationSite> site;
330 bool is_strong = (flags & ArrayLiteral::kIsStrong) != 0;
321 ASSIGN_RETURN_ON_EXCEPTION( 331 ASSIGN_RETURN_ON_EXCEPTION(
322 isolate, site, 332 isolate, site,
323 GetLiteralAllocationSite(isolate, literals, literals_index, elements), 333 GetLiteralAllocationSite(isolate, literals, literals_index, elements,
334 is_strong),
324 JSObject); 335 JSObject);
325 336
326 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; 337 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0;
327 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); 338 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
328 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); 339 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
329 usage_context.EnterNewScope(); 340 usage_context.EnterNewScope();
330 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 341 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0
331 ? JSObject::kNoHints 342 ? JSObject::kNoHints
332 : JSObject::kObjectIsShallow; 343 : JSObject::kObjectIsShallow;
333 MaybeHandle<JSObject> copy = 344 MaybeHandle<JSObject> copy =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); 430 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind);
420 } 431 }
421 } 432 }
422 FixedArray* object_array = FixedArray::cast(object->elements()); 433 FixedArray* object_array = FixedArray::cast(object->elements());
423 object_array->set(store_index, *value); 434 object_array->set(store_index, *value);
424 } 435 }
425 return *object; 436 return *object;
426 } 437 }
427 } 438 }
428 } // namespace v8::internal 439 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/strong/literals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698