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

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

Issue 1734243004: Remove strong mode support from materialized literals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test expectations. Created 4 years, 10 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/cctest/test-api.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/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"
11 #include "src/parsing/parser.h" 11 #include "src/parsing/parser.h"
12 #include "src/runtime/runtime.h" 12 #include "src/runtime/runtime.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_strong, bool* is_result_from_cache) { 19 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_strong, is_result_from_cache); 33 context, number_of_properties, false, 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<LiteralsArray> literals, 37 Isolate* isolate, Handle<LiteralsArray> literals,
38 Handle<FixedArray> constant_properties, bool is_strong); 38 Handle<FixedArray> constant_properties);
39
40 39
41 MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( 40 MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
42 Isolate* isolate, Handle<LiteralsArray> literals, 41 Isolate* isolate, Handle<LiteralsArray> literals,
43 Handle<FixedArray> constant_properties, bool should_have_fast_elements, 42 Handle<FixedArray> constant_properties, bool should_have_fast_elements,
44 bool has_function_literal, bool is_strong) { 43 bool has_function_literal) {
45 Handle<Context> context = isolate->native_context(); 44 Handle<Context> context = isolate->native_context();
46 45
47 // In case we have function literals, we want the object to be in 46 // 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 47 // 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 48 // maps with constant functions can't be shared if the functions are
50 // not the same (which is the common case). 49 // not the same (which is the common case).
51 bool is_result_from_cache = false; 50 bool is_result_from_cache = false;
52 Handle<Map> map = has_function_literal 51 Handle<Map> map = has_function_literal
53 ? Handle<Map>(is_strong 52 ? Handle<Map>(context->object_function()->initial_map())
54 ? context->js_object_strong_map() 53 : ComputeObjectLiteralMap(context, constant_properties,
55 : context->object_function()->initial_map()) 54 &is_result_from_cache);
56 : ComputeObjectLiteralMap(context, constant_properties, is_strong,
57 &is_result_from_cache);
58 55
59 PretenureFlag pretenure_flag = 56 PretenureFlag pretenure_flag =
60 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; 57 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
61 58
62 Handle<JSObject> boilerplate = 59 Handle<JSObject> boilerplate =
63 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); 60 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag);
64 61
65 // Normalize the elements of the boilerplate to save space if needed. 62 // Normalize the elements of the boilerplate to save space if needed.
66 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); 63 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate);
67 64
68 // Add the constant properties to the boilerplate. 65 // Add the constant properties to the boilerplate.
69 int length = constant_properties->length(); 66 int length = constant_properties->length();
70 bool should_transform = 67 bool should_transform =
71 !is_result_from_cache && boilerplate->HasFastProperties(); 68 !is_result_from_cache && boilerplate->HasFastProperties();
72 bool should_normalize = should_transform || has_function_literal; 69 bool should_normalize = should_transform || has_function_literal;
73 if (should_normalize) { 70 if (should_normalize) {
74 // TODO(verwaest): We might not want to ever normalize here. 71 // TODO(verwaest): We might not want to ever normalize here.
75 JSObject::NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES, 72 JSObject::NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES,
76 length / 2, "Boilerplate"); 73 length / 2, "Boilerplate");
77 } 74 }
78 // TODO(verwaest): Support tracking representations in the boilerplate. 75 // TODO(verwaest): Support tracking representations in the boilerplate.
79 for (int index = 0; index < length; index += 2) { 76 for (int index = 0; index < length; index += 2) {
80 Handle<Object> key(constant_properties->get(index + 0), isolate); 77 Handle<Object> key(constant_properties->get(index + 0), isolate);
81 Handle<Object> value(constant_properties->get(index + 1), isolate); 78 Handle<Object> value(constant_properties->get(index + 1), isolate);
82 if (value->IsFixedArray()) { 79 if (value->IsFixedArray()) {
83 // The value contains the constant_properties of a 80 // The value contains the constant_properties of a
84 // simple object or array literal. 81 // simple object or array literal.
85 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 82 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
86 ASSIGN_RETURN_ON_EXCEPTION( 83 ASSIGN_RETURN_ON_EXCEPTION(
87 isolate, value, 84 isolate, value, CreateLiteralBoilerplate(isolate, literals, array),
88 CreateLiteralBoilerplate(isolate, literals, array, is_strong),
89 Object); 85 Object);
90 } 86 }
91 MaybeHandle<Object> maybe_result; 87 MaybeHandle<Object> maybe_result;
92 uint32_t element_index = 0; 88 uint32_t element_index = 0;
93 if (key->IsInternalizedString()) { 89 if (key->IsInternalizedString()) {
94 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 90 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
95 // Array index as string (uint32). 91 // Array index as string (uint32).
96 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 92 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
97 maybe_result = JSObject::SetOwnElementIgnoreAttributes( 93 maybe_result = JSObject::SetOwnElementIgnoreAttributes(
98 boilerplate, element_index, value, NONE); 94 boilerplate, element_index, value, NONE);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // computed properties have been assigned so that we can generate 126 // computed properties have been assigned so that we can generate
131 // constant function properties. 127 // constant function properties.
132 if (should_transform && !has_function_literal) { 128 if (should_transform && !has_function_literal) {
133 JSObject::MigrateSlowToFast(boilerplate, 129 JSObject::MigrateSlowToFast(boilerplate,
134 boilerplate->map()->unused_property_fields(), 130 boilerplate->map()->unused_property_fields(),
135 "FastLiteral"); 131 "FastLiteral");
136 } 132 }
137 return boilerplate; 133 return boilerplate;
138 } 134 }
139 135
140
141 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( 136 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
142 Isolate* isolate, Handle<LiteralsArray> literals, 137 Isolate* isolate, Handle<LiteralsArray> literals,
143 Handle<FixedArray> elements, bool is_strong) { 138 Handle<FixedArray> elements) {
144 // Create the JSArray. 139 // Create the JSArray.
145 Handle<JSFunction> constructor = isolate->array_function(); 140 Handle<JSFunction> constructor = isolate->array_function();
146 141
147 PretenureFlag pretenure_flag = 142 PretenureFlag pretenure_flag =
148 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; 143 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
149 144
150 Handle<JSArray> object = Handle<JSArray>::cast( 145 Handle<JSArray> object = Handle<JSArray>::cast(
151 isolate->factory()->NewJSObject(constructor, pretenure_flag)); 146 isolate->factory()->NewJSObject(constructor, pretenure_flag));
152 147
153 ElementsKind constant_elements_kind = 148 ElementsKind constant_elements_kind =
154 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); 149 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value());
155 Handle<FixedArrayBase> constant_elements_values( 150 Handle<FixedArrayBase> constant_elements_values(
156 FixedArrayBase::cast(elements->get(1))); 151 FixedArrayBase::cast(elements->get(1)));
157 152
158 { 153 {
159 DisallowHeapAllocation no_gc; 154 DisallowHeapAllocation no_gc;
160 DCHECK(IsFastElementsKind(constant_elements_kind)); 155 DCHECK(IsFastElementsKind(constant_elements_kind));
161 Context* native_context = isolate->context()->native_context(); 156 Context* native_context = isolate->context()->native_context();
162 Strength strength = is_strong ? Strength::STRONG : Strength::WEAK; 157 Object* map =
163 Object* map = native_context->get( 158 native_context->get(Context::ArrayMapIndex(constant_elements_kind));
164 Context::ArrayMapIndex(constant_elements_kind, strength));
165 object->set_map(Map::cast(map)); 159 object->set_map(Map::cast(map));
166 } 160 }
167 161
168 Handle<FixedArrayBase> copied_elements_values; 162 Handle<FixedArrayBase> copied_elements_values;
169 if (IsFastDoubleElementsKind(constant_elements_kind)) { 163 if (IsFastDoubleElementsKind(constant_elements_kind)) {
170 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( 164 copied_elements_values = isolate->factory()->CopyFixedDoubleArray(
171 Handle<FixedDoubleArray>::cast(constant_elements_values)); 165 Handle<FixedDoubleArray>::cast(constant_elements_values));
172 } else { 166 } else {
173 DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind)); 167 DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind));
174 const bool is_cow = (constant_elements_values->map() == 168 const bool is_cow = (constant_elements_values->map() ==
(...skipping 14 matching lines...) Expand all
189 isolate->factory()->CopyFixedArray(fixed_array_values); 183 isolate->factory()->CopyFixedArray(fixed_array_values);
190 copied_elements_values = fixed_array_values_copy; 184 copied_elements_values = fixed_array_values_copy;
191 for (int i = 0; i < fixed_array_values->length(); i++) { 185 for (int i = 0; i < fixed_array_values->length(); i++) {
192 HandleScope scope(isolate); 186 HandleScope scope(isolate);
193 if (fixed_array_values->get(i)->IsFixedArray()) { 187 if (fixed_array_values->get(i)->IsFixedArray()) {
194 // The value contains the constant_properties of a 188 // The value contains the constant_properties of a
195 // simple object or array literal. 189 // simple object or array literal.
196 Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i))); 190 Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i)));
197 Handle<Object> result; 191 Handle<Object> result;
198 ASSIGN_RETURN_ON_EXCEPTION( 192 ASSIGN_RETURN_ON_EXCEPTION(
199 isolate, result, 193 isolate, result, CreateLiteralBoilerplate(isolate, literals, fa),
200 CreateLiteralBoilerplate(isolate, literals, fa, is_strong),
201 Object); 194 Object);
202 fixed_array_values_copy->set(i, *result); 195 fixed_array_values_copy->set(i, *result);
203 } 196 }
204 } 197 }
205 } 198 }
206 } 199 }
207 object->set_elements(*copied_elements_values); 200 object->set_elements(*copied_elements_values);
208 object->set_length(Smi::FromInt(copied_elements_values->length())); 201 object->set_length(Smi::FromInt(copied_elements_values->length()));
209 202
210 JSObject::ValidateElements(object); 203 JSObject::ValidateElements(object);
211 return object; 204 return object;
212 } 205 }
213 206
214
215 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( 207 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
216 Isolate* isolate, Handle<LiteralsArray> literals, Handle<FixedArray> array, 208 Isolate* isolate, Handle<LiteralsArray> literals,
217 bool is_strong) { 209 Handle<FixedArray> array) {
218 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); 210 Handle<FixedArray> elements = CompileTimeValue::GetElements(array);
219 const bool kHasNoFunctionLiteral = false; 211 const bool kHasNoFunctionLiteral = false;
220 switch (CompileTimeValue::GetLiteralType(array)) { 212 switch (CompileTimeValue::GetLiteralType(array)) {
221 case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS: 213 case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS:
222 return CreateObjectLiteralBoilerplate(isolate, literals, elements, true, 214 return CreateObjectLiteralBoilerplate(isolate, literals, elements, true,
223 kHasNoFunctionLiteral, is_strong); 215 kHasNoFunctionLiteral);
224 case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS: 216 case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
225 return CreateObjectLiteralBoilerplate(isolate, literals, elements, false, 217 return CreateObjectLiteralBoilerplate(isolate, literals, elements, false,
226 kHasNoFunctionLiteral, is_strong); 218 kHasNoFunctionLiteral);
227 case CompileTimeValue::ARRAY_LITERAL: 219 case CompileTimeValue::ARRAY_LITERAL:
228 return Runtime::CreateArrayLiteralBoilerplate(isolate, literals, 220 return Runtime::CreateArrayLiteralBoilerplate(isolate, literals,
229 elements, is_strong); 221 elements);
230 default: 222 default:
231 UNREACHABLE(); 223 UNREACHABLE();
232 return MaybeHandle<Object>(); 224 return MaybeHandle<Object>();
233 } 225 }
234 } 226 }
235 227
236 228
237 RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { 229 RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
238 HandleScope scope(isolate); 230 HandleScope scope(isolate);
239 DCHECK_EQ(4, args.length()); 231 DCHECK_EQ(4, args.length());
(...skipping 17 matching lines...) Expand all
257 HandleScope scope(isolate); 249 HandleScope scope(isolate);
258 DCHECK_EQ(4, args.length()); 250 DCHECK_EQ(4, args.length());
259 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); 251 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0);
260 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 252 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
261 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 253 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
262 CONVERT_SMI_ARG_CHECKED(flags, 3); 254 CONVERT_SMI_ARG_CHECKED(flags, 3);
263 Handle<LiteralsArray> literals(closure->literals(), isolate); 255 Handle<LiteralsArray> literals(closure->literals(), isolate);
264 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 256 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
265 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 257 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
266 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; 258 bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0;
267 bool is_strong = (flags & ObjectLiteral::kIsStrong) != 0;
268 259
269 RUNTIME_ASSERT(literals_index >= 0 && 260 RUNTIME_ASSERT(literals_index >= 0 &&
270 literals_index < literals->literals_count()); 261 literals_index < literals->literals_count());
271 262
272 // Check if boilerplate exists. If not, create it first. 263 // Check if boilerplate exists. If not, create it first.
273 Handle<Object> literal_site(literals->literal(literals_index), isolate); 264 Handle<Object> literal_site(literals->literal(literals_index), isolate);
274 Handle<AllocationSite> site; 265 Handle<AllocationSite> site;
275 Handle<JSObject> boilerplate; 266 Handle<JSObject> boilerplate;
276 if (*literal_site == isolate->heap()->undefined_value()) { 267 if (*literal_site == isolate->heap()->undefined_value()) {
277 Handle<Object> raw_boilerplate; 268 Handle<Object> raw_boilerplate;
278 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 269 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
279 isolate, raw_boilerplate, 270 isolate, raw_boilerplate,
280 CreateObjectLiteralBoilerplate(isolate, literals, constant_properties, 271 CreateObjectLiteralBoilerplate(isolate, literals, constant_properties,
281 should_have_fast_elements, 272 should_have_fast_elements,
282 has_function_literal, is_strong)); 273 has_function_literal));
283 boilerplate = Handle<JSObject>::cast(raw_boilerplate); 274 boilerplate = Handle<JSObject>::cast(raw_boilerplate);
284 275
285 AllocationSiteCreationContext creation_context(isolate); 276 AllocationSiteCreationContext creation_context(isolate);
286 site = creation_context.EnterNewScope(); 277 site = creation_context.EnterNewScope();
287 RETURN_FAILURE_ON_EXCEPTION( 278 RETURN_FAILURE_ON_EXCEPTION(
288 isolate, JSObject::DeepWalk(boilerplate, &creation_context)); 279 isolate, JSObject::DeepWalk(boilerplate, &creation_context));
289 creation_context.ExitScope(site, boilerplate); 280 creation_context.ExitScope(site, boilerplate);
290 281
291 // Update the functions literal and return the boilerplate. 282 // Update the functions literal and return the boilerplate.
292 literals->set_literal(literals_index, *site); 283 literals->set_literal(literals_index, *site);
293 } else { 284 } else {
294 site = Handle<AllocationSite>::cast(literal_site); 285 site = Handle<AllocationSite>::cast(literal_site);
295 boilerplate = 286 boilerplate =
296 Handle<JSObject>(JSObject::cast(site->transition_info()), isolate); 287 Handle<JSObject>(JSObject::cast(site->transition_info()), isolate);
297 } 288 }
298 289
299 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); 290 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
300 usage_context.EnterNewScope(); 291 usage_context.EnterNewScope();
301 MaybeHandle<Object> maybe_copy = 292 MaybeHandle<Object> maybe_copy =
302 JSObject::DeepCopy(boilerplate, &usage_context); 293 JSObject::DeepCopy(boilerplate, &usage_context);
303 usage_context.ExitScope(site, boilerplate); 294 usage_context.ExitScope(site, boilerplate);
304 Handle<Object> copy; 295 Handle<Object> copy;
305 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy); 296 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy);
306 return *copy; 297 return *copy;
307 } 298 }
308 299
309
310 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( 300 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
311 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index, 301 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index,
312 Handle<FixedArray> elements, bool is_strong) { 302 Handle<FixedArray> elements) {
313 // Check if boilerplate exists. If not, create it first. 303 // Check if boilerplate exists. If not, create it first.
314 Handle<Object> literal_site(literals->literal(literals_index), isolate); 304 Handle<Object> literal_site(literals->literal(literals_index), isolate);
315 Handle<AllocationSite> site; 305 Handle<AllocationSite> site;
316 if (*literal_site == isolate->heap()->undefined_value()) { 306 if (*literal_site == isolate->heap()->undefined_value()) {
317 DCHECK(*elements != isolate->heap()->empty_fixed_array()); 307 DCHECK(*elements != isolate->heap()->empty_fixed_array());
318 Handle<Object> boilerplate; 308 Handle<Object> boilerplate;
319 ASSIGN_RETURN_ON_EXCEPTION( 309 ASSIGN_RETURN_ON_EXCEPTION(
320 isolate, boilerplate, 310 isolate, boilerplate,
321 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements, 311 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements),
322 is_strong),
323 AllocationSite); 312 AllocationSite);
324 313
325 AllocationSiteCreationContext creation_context(isolate); 314 AllocationSiteCreationContext creation_context(isolate);
326 site = creation_context.EnterNewScope(); 315 site = creation_context.EnterNewScope();
327 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), 316 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate),
328 &creation_context).is_null()) { 317 &creation_context).is_null()) {
329 return Handle<AllocationSite>::null(); 318 return Handle<AllocationSite>::null();
330 } 319 }
331 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate)); 320 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate));
332 321
333 literals->set_literal(literals_index, *site); 322 literals->set_literal(literals_index, *site);
334 } else { 323 } else {
335 site = Handle<AllocationSite>::cast(literal_site); 324 site = Handle<AllocationSite>::cast(literal_site);
336 } 325 }
337 326
338 return site; 327 return site;
339 } 328 }
340 329
341 330
342 static MaybeHandle<JSObject> CreateArrayLiteralImpl( 331 static MaybeHandle<JSObject> CreateArrayLiteralImpl(
343 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index, 332 Isolate* isolate, Handle<LiteralsArray> literals, int literals_index,
344 Handle<FixedArray> elements, int flags) { 333 Handle<FixedArray> elements, int flags) {
345 RUNTIME_ASSERT_HANDLIFIED( 334 RUNTIME_ASSERT_HANDLIFIED(
346 literals_index >= 0 && literals_index < literals->literals_count(), 335 literals_index >= 0 && literals_index < literals->literals_count(),
347 JSObject); 336 JSObject);
348 Handle<AllocationSite> site; 337 Handle<AllocationSite> site;
349 bool is_strong = (flags & ArrayLiteral::kIsStrong) != 0;
350 ASSIGN_RETURN_ON_EXCEPTION( 338 ASSIGN_RETURN_ON_EXCEPTION(
351 isolate, site, 339 isolate, site,
352 GetLiteralAllocationSite(isolate, literals, literals_index, elements, 340 GetLiteralAllocationSite(isolate, literals, literals_index, elements),
353 is_strong),
354 JSObject); 341 JSObject);
355 342
356 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; 343 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0;
357 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); 344 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
358 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); 345 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
359 usage_context.EnterNewScope(); 346 usage_context.EnterNewScope();
360 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 347 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0
361 ? JSObject::kNoHints 348 ? JSObject::kNoHints
362 : JSObject::kObjectIsShallow; 349 : JSObject::kObjectIsShallow;
363 MaybeHandle<JSObject> copy = 350 MaybeHandle<JSObject> copy =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 Handle<LiteralsArray> literals(closure->literals(), isolate); 382 Handle<LiteralsArray> literals(closure->literals(), isolate);
396 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 383 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
397 isolate, result, 384 isolate, result,
398 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, 385 CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
399 ArrayLiteral::kShallowElements)); 386 ArrayLiteral::kShallowElements));
400 return *result; 387 return *result;
401 } 388 }
402 389
403 } // namespace internal 390 } // namespace internal
404 } // namespace v8 391 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698