OLD | NEW |
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 30 matching lines...) Expand all Loading... |
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, bool is_strong) { | 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 | |
52 bool is_result_from_cache = false; | 51 bool is_result_from_cache = false; |
53 Handle<Map> map = has_function_literal | 52 Handle<Map> map = has_function_literal |
54 ? Handle<Map>(context->object_function()->initial_map()) | 53 ? Handle<Map>(is_strong |
55 : ComputeObjectLiteralMap(context, constant_properties, | 54 ? context->js_object_strong_map() |
56 is_strong, | 55 : context->object_function()->initial_map()) |
57 &is_result_from_cache); | 56 : ComputeObjectLiteralMap(context, constant_properties, is_strong, |
| 57 &is_result_from_cache); |
58 | 58 |
59 PretenureFlag pretenure_flag = | 59 PretenureFlag pretenure_flag = |
60 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; | 60 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; |
61 | 61 |
62 Handle<JSObject> boilerplate = | 62 Handle<JSObject> boilerplate = |
63 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); | 63 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); |
64 | 64 |
65 // Normalize the elements of the boilerplate to save space if needed. | 65 // Normalize the elements of the boilerplate to save space if needed. |
66 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); | 66 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); |
67 | 67 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |