| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 5102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5113 AllocationSiteUsageContext usage_context(isolate(), site, false); | 5113 AllocationSiteUsageContext usage_context(isolate(), site, false); |
| 5114 usage_context.EnterNewScope(); | 5114 usage_context.EnterNewScope(); |
| 5115 literal = BuildFastLiteral(boilerplate_object, &usage_context); | 5115 literal = BuildFastLiteral(boilerplate_object, &usage_context); |
| 5116 usage_context.ExitScope(site, boilerplate_object); | 5116 usage_context.ExitScope(site, boilerplate_object); |
| 5117 } else { | 5117 } else { |
| 5118 NoObservableSideEffectsScope no_effects(this); | 5118 NoObservableSideEffectsScope no_effects(this); |
| 5119 // Boilerplate already exists and constant elements are never accessed, | 5119 // Boilerplate already exists and constant elements are never accessed, |
| 5120 // pass an empty fixed array to the runtime function instead. | 5120 // pass an empty fixed array to the runtime function instead. |
| 5121 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | 5121 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); |
| 5122 int literal_index = expr->literal_index(); | 5122 int literal_index = expr->literal_index(); |
| 5123 int flags = expr->depth() == 1 |
| 5124 ? ArrayLiteral::kShallowElements |
| 5125 : ArrayLiteral::kNoFlags; |
| 5126 flags |= ArrayLiteral::kDisableMementos; |
| 5123 | 5127 |
| 5124 Add<HPushArgument>(Add<HConstant>(literals)); | 5128 Add<HPushArgument>(Add<HConstant>(literals)); |
| 5125 Add<HPushArgument>(Add<HConstant>(literal_index)); | 5129 Add<HPushArgument>(Add<HConstant>(literal_index)); |
| 5126 Add<HPushArgument>(Add<HConstant>(constants)); | 5130 Add<HPushArgument>(Add<HConstant>(constants)); |
| 5131 Add<HPushArgument>(Add<HConstant>(flags)); |
| 5127 | 5132 |
| 5128 // TODO(mvstanton): Consider a flag to turn off creation of any | 5133 // TODO(mvstanton): Consider a flag to turn off creation of any |
| 5129 // AllocationMementos for this call: we are in crankshaft and should have | 5134 // AllocationMementos for this call: we are in crankshaft and should have |
| 5130 // learned enough about transition behavior to stop emitting mementos. | 5135 // learned enough about transition behavior to stop emitting mementos. |
| 5131 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; | 5136 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; |
| 5132 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), | 5137 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), |
| 5133 Runtime::FunctionForId(function_id), | 5138 Runtime::FunctionForId(function_id), |
| 5134 3); | 5139 4); |
| 5135 | 5140 |
| 5136 // De-opt if elements kind changed from boilerplate_elements_kind. | 5141 // De-opt if elements kind changed from boilerplate_elements_kind. |
| 5137 Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate()); | 5142 Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate()); |
| 5138 literal = Add<HCheckMaps>(literal, map, top_info()); | 5143 literal = Add<HCheckMaps>(literal, map, top_info()); |
| 5139 } | 5144 } |
| 5140 | 5145 |
| 5141 // The array is expected in the bailout environment during computation | 5146 // The array is expected in the bailout environment during computation |
| 5142 // of the property values and is the value of the entire expression. | 5147 // of the property values and is the value of the entire expression. |
| 5143 Push(literal); | 5148 Push(literal); |
| 5144 // The literal index is on the stack, too. | 5149 // The literal index is on the stack, too. |
| (...skipping 4049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9194 return New<HConstant>( | 9199 return New<HConstant>( |
| 9195 function_state()->compilation_info()->closure()); | 9200 function_state()->compilation_info()->closure()); |
| 9196 } else { | 9201 } else { |
| 9197 return New<HThisFunction>(); | 9202 return New<HThisFunction>(); |
| 9198 } | 9203 } |
| 9199 } | 9204 } |
| 9200 | 9205 |
| 9201 | 9206 |
| 9202 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( | 9207 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
| 9203 Handle<JSObject> boilerplate_object, | 9208 Handle<JSObject> boilerplate_object, |
| 9204 AllocationSiteContext* site_context) { | 9209 AllocationSiteUsageContext* site_context) { |
| 9205 NoObservableSideEffectsScope no_effects(this); | 9210 NoObservableSideEffectsScope no_effects(this); |
| 9206 InstanceType instance_type = boilerplate_object->map()->instance_type(); | 9211 InstanceType instance_type = boilerplate_object->map()->instance_type(); |
| 9207 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); | 9212 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); |
| 9208 | 9213 |
| 9209 HType type = instance_type == JS_ARRAY_TYPE | 9214 HType type = instance_type == JS_ARRAY_TYPE |
| 9210 ? HType::JSArray() : HType::JSObject(); | 9215 ? HType::JSArray() : HType::JSObject(); |
| 9211 HValue* object_size_constant = Add<HConstant>( | 9216 HValue* object_size_constant = Add<HConstant>( |
| 9212 boilerplate_object->map()->instance_size()); | 9217 boilerplate_object->map()->instance_size()); |
| 9213 HInstruction* object = Add<HAllocate>(object_size_constant, type, | 9218 HInstruction* object = Add<HAllocate>(object_size_constant, type, |
| 9214 isolate()->heap()->GetPretenureMode(), instance_type); | 9219 isolate()->heap()->GetPretenureMode(), instance_type); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9287 object_elements = Add<HConstant>(elements_field); | 9292 object_elements = Add<HConstant>(elements_field); |
| 9288 } | 9293 } |
| 9289 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 9294 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 9290 object_elements); | 9295 object_elements); |
| 9291 } | 9296 } |
| 9292 | 9297 |
| 9293 | 9298 |
| 9294 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( | 9299 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
| 9295 Handle<JSObject> boilerplate_object, | 9300 Handle<JSObject> boilerplate_object, |
| 9296 HInstruction* object, | 9301 HInstruction* object, |
| 9297 AllocationSiteContext* site_context) { | 9302 AllocationSiteUsageContext* site_context) { |
| 9298 Handle<DescriptorArray> descriptors( | 9303 Handle<DescriptorArray> descriptors( |
| 9299 boilerplate_object->map()->instance_descriptors()); | 9304 boilerplate_object->map()->instance_descriptors()); |
| 9300 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); | 9305 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); |
| 9301 | 9306 |
| 9302 int copied_fields = 0; | 9307 int copied_fields = 0; |
| 9303 for (int i = 0; i < limit; i++) { | 9308 for (int i = 0; i < limit; i++) { |
| 9304 PropertyDetails details = descriptors->GetDetails(i); | 9309 PropertyDetails details = descriptors->GetDetails(i); |
| 9305 if (details.type() != FIELD) continue; | 9310 if (details.type() != FIELD) continue; |
| 9306 copied_fields++; | 9311 copied_fields++; |
| 9307 int index = descriptors->GetFieldIndex(i); | 9312 int index = descriptors->GetFieldIndex(i); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9359 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); | 9364 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); |
| 9360 Add<HStoreNamedField>(object, access, value_instruction); | 9365 Add<HStoreNamedField>(object, access, value_instruction); |
| 9361 } | 9366 } |
| 9362 } | 9367 } |
| 9363 | 9368 |
| 9364 | 9369 |
| 9365 void HOptimizedGraphBuilder::BuildEmitElements( | 9370 void HOptimizedGraphBuilder::BuildEmitElements( |
| 9366 Handle<JSObject> boilerplate_object, | 9371 Handle<JSObject> boilerplate_object, |
| 9367 Handle<FixedArrayBase> elements, | 9372 Handle<FixedArrayBase> elements, |
| 9368 HValue* object_elements, | 9373 HValue* object_elements, |
| 9369 AllocationSiteContext* site_context) { | 9374 AllocationSiteUsageContext* site_context) { |
| 9370 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 9375 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
| 9371 int elements_length = elements->length(); | 9376 int elements_length = elements->length(); |
| 9372 HValue* object_elements_length = Add<HConstant>(elements_length); | 9377 HValue* object_elements_length = Add<HConstant>(elements_length); |
| 9373 BuildInitializeElementsHeader(object_elements, kind, object_elements_length); | 9378 BuildInitializeElementsHeader(object_elements, kind, object_elements_length); |
| 9374 | 9379 |
| 9375 // Copy elements backing store content. | 9380 // Copy elements backing store content. |
| 9376 if (elements->IsFixedDoubleArray()) { | 9381 if (elements->IsFixedDoubleArray()) { |
| 9377 BuildEmitFixedDoubleArray(elements, kind, object_elements); | 9382 BuildEmitFixedDoubleArray(elements, kind, object_elements); |
| 9378 } else if (elements->IsFixedArray()) { | 9383 } else if (elements->IsFixedArray()) { |
| 9379 BuildEmitFixedArray(elements, kind, object_elements, | 9384 BuildEmitFixedArray(elements, kind, object_elements, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 9400 value_instruction, kind); | 9405 value_instruction, kind); |
| 9401 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 9406 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
| 9402 } | 9407 } |
| 9403 } | 9408 } |
| 9404 | 9409 |
| 9405 | 9410 |
| 9406 void HOptimizedGraphBuilder::BuildEmitFixedArray( | 9411 void HOptimizedGraphBuilder::BuildEmitFixedArray( |
| 9407 Handle<FixedArrayBase> elements, | 9412 Handle<FixedArrayBase> elements, |
| 9408 ElementsKind kind, | 9413 ElementsKind kind, |
| 9409 HValue* object_elements, | 9414 HValue* object_elements, |
| 9410 AllocationSiteContext* site_context) { | 9415 AllocationSiteUsageContext* site_context) { |
| 9411 HInstruction* boilerplate_elements = Add<HConstant>(elements); | 9416 HInstruction* boilerplate_elements = Add<HConstant>(elements); |
| 9412 int elements_length = elements->length(); | 9417 int elements_length = elements->length(); |
| 9413 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); | 9418 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); |
| 9414 for (int i = 0; i < elements_length; i++) { | 9419 for (int i = 0; i < elements_length; i++) { |
| 9415 Handle<Object> value(fast_elements->get(i), isolate()); | 9420 Handle<Object> value(fast_elements->get(i), isolate()); |
| 9416 HValue* key_constant = Add<HConstant>(i); | 9421 HValue* key_constant = Add<HConstant>(i); |
| 9417 if (value->IsJSObject()) { | 9422 if (value->IsJSObject()) { |
| 9418 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9423 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 9419 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 9424 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
| 9420 HInstruction* result = | 9425 HInstruction* result = |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10670 if (ShouldProduceTraceOutput()) { | 10675 if (ShouldProduceTraceOutput()) { |
| 10671 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10676 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10672 } | 10677 } |
| 10673 | 10678 |
| 10674 #ifdef DEBUG | 10679 #ifdef DEBUG |
| 10675 graph_->Verify(false); // No full verify. | 10680 graph_->Verify(false); // No full verify. |
| 10676 #endif | 10681 #endif |
| 10677 } | 10682 } |
| 10678 | 10683 |
| 10679 } } // namespace v8::internal | 10684 } } // namespace v8::internal |
| OLD | NEW |