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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); | 102 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); |
103 | 103 |
104 // Add the constant properties to the boilerplate. | 104 // Add the constant properties to the boilerplate. |
105 int length = constant_properties->length(); | 105 int length = constant_properties->length(); |
106 bool should_transform = | 106 bool should_transform = |
107 !is_result_from_cache && boilerplate->HasFastProperties(); | 107 !is_result_from_cache && boilerplate->HasFastProperties(); |
108 bool should_normalize = should_transform || has_function_literal; | 108 bool should_normalize = should_transform || has_function_literal; |
109 if (should_normalize) { | 109 if (should_normalize) { |
110 // TODO(verwaest): We might not want to ever normalize here. | 110 // TODO(verwaest): We might not want to ever normalize here. |
111 JSObject::NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES, | 111 JSObject::NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES, |
112 length / 2); | 112 length / 2, "Boilerplate"); |
113 } | 113 } |
114 // TODO(verwaest): Support tracking representations in the boilerplate. | 114 // TODO(verwaest): Support tracking representations in the boilerplate. |
115 for (int index = 0; index < length; index += 2) { | 115 for (int index = 0; index < length; index += 2) { |
116 Handle<Object> key(constant_properties->get(index + 0), isolate); | 116 Handle<Object> key(constant_properties->get(index + 0), isolate); |
117 Handle<Object> value(constant_properties->get(index + 1), isolate); | 117 Handle<Object> value(constant_properties->get(index + 1), isolate); |
118 if (value->IsFixedArray()) { | 118 if (value->IsFixedArray()) { |
119 // The value contains the constant_properties of a | 119 // The value contains the constant_properties of a |
120 // simple object or array literal. | 120 // simple object or array literal. |
121 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 121 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
122 ASSIGN_RETURN_ON_EXCEPTION( | 122 ASSIGN_RETURN_ON_EXCEPTION( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // convert back to an exception. | 159 // convert back to an exception. |
160 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); | 160 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); |
161 } | 161 } |
162 | 162 |
163 // Transform to fast properties if necessary. For object literals with | 163 // Transform to fast properties if necessary. For object literals with |
164 // containing function literals we defer this operation until after all | 164 // containing function literals we defer this operation until after all |
165 // computed properties have been assigned so that we can generate | 165 // computed properties have been assigned so that we can generate |
166 // constant function properties. | 166 // constant function properties. |
167 if (should_transform && !has_function_literal) { | 167 if (should_transform && !has_function_literal) { |
168 JSObject::MigrateSlowToFast(boilerplate, | 168 JSObject::MigrateSlowToFast(boilerplate, |
169 boilerplate->map()->unused_property_fields()); | 169 boilerplate->map()->unused_property_fields(), |
| 170 "FastLiteral"); |
170 } | 171 } |
171 | 172 |
172 return boilerplate; | 173 return boilerplate; |
173 } | 174 } |
174 | 175 |
175 | 176 |
176 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( | 177 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( |
177 Isolate* isolate, Handle<FixedArray> literals, | 178 Isolate* isolate, Handle<FixedArray> literals, |
178 Handle<FixedArray> elements) { | 179 Handle<FixedArray> elements) { |
179 // Create the JSArray. | 180 // Create the JSArray. |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); | 458 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); |
458 } | 459 } |
459 } | 460 } |
460 FixedArray* object_array = FixedArray::cast(object->elements()); | 461 FixedArray* object_array = FixedArray::cast(object->elements()); |
461 object_array->set(store_index, *value); | 462 object_array->set(store_index, *value); |
462 } | 463 } |
463 return *object; | 464 return *object; |
464 } | 465 } |
465 } | 466 } |
466 } // namespace v8::internal | 467 } // namespace v8::internal |
OLD | NEW |