Chromium Code Reviews

Side by Side Diff: src/hydrogen.cc

Issue 24250005: AllocationSites for all literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Change to abstract base class Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...)
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "hydrogen.h" 28 #include "hydrogen.h"
29 29
30 #include <algorithm> 30 #include <algorithm>
31 31
32 #include "v8.h" 32 #include "v8.h"
33 #include "allocation-site-scopes.h"
33 #include "codegen.h" 34 #include "codegen.h"
34 #include "full-codegen.h" 35 #include "full-codegen.h"
35 #include "hashmap.h" 36 #include "hashmap.h"
36 #include "hydrogen-bce.h" 37 #include "hydrogen-bce.h"
37 #include "hydrogen-bch.h" 38 #include "hydrogen-bch.h"
38 #include "hydrogen-canonicalize.h" 39 #include "hydrogen-canonicalize.h"
39 #include "hydrogen-check-elimination.h" 40 #include "hydrogen-check-elimination.h"
40 #include "hydrogen-dce.h" 41 #include "hydrogen-dce.h"
41 #include "hydrogen-dehoist.h" 42 #include "hydrogen-dehoist.h"
42 #include "hydrogen-environment-liveness.h" 43 #include "hydrogen-environment-liveness.h"
(...skipping 4298 matching lines...)
4341 Handle<JSObject> boilerplate; 4342 Handle<JSObject> boilerplate;
4342 if (!literals_cell->IsUndefined()) { 4343 if (!literals_cell->IsUndefined()) {
4343 // Retrieve the boilerplate 4344 // Retrieve the boilerplate
4344 site = Handle<AllocationSite>::cast(literals_cell); 4345 site = Handle<AllocationSite>::cast(literals_cell);
4345 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), 4346 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()),
4346 isolate()); 4347 isolate());
4347 } 4348 }
4348 4349
4349 if (!boilerplate.is_null() && 4350 if (!boilerplate.is_null() &&
4350 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { 4351 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
4351 literal = BuildFastLiteral(boilerplate); 4352 AllocationSiteUsageContext usage_context(isolate(), site, false);
4353 usage_context.EnterNewScope();
4354 literal = BuildFastLiteral(boilerplate, &usage_context);
4355 usage_context.ExitScope(site, boilerplate);
4352 } else { 4356 } else {
4353 NoObservableSideEffectsScope no_effects(this); 4357 NoObservableSideEffectsScope no_effects(this);
4354 Handle<FixedArray> closure_literals(closure->literals(), isolate()); 4358 Handle<FixedArray> closure_literals(closure->literals(), isolate());
4355 Handle<FixedArray> constant_properties = expr->constant_properties(); 4359 Handle<FixedArray> constant_properties = expr->constant_properties();
4356 int literal_index = expr->literal_index(); 4360 int literal_index = expr->literal_index();
4357 int flags = expr->fast_elements() 4361 int flags = expr->fast_elements()
4358 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; 4362 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags;
4359 flags |= expr->has_function() 4363 flags |= expr->has_function()
4360 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; 4364 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
4361 4365
4362 Add<HPushArgument>(Add<HConstant>(closure_literals)); 4366 Add<HPushArgument>(Add<HConstant>(closure_literals));
4363 Add<HPushArgument>(Add<HConstant>(literal_index)); 4367 Add<HPushArgument>(Add<HConstant>(literal_index));
4364 Add<HPushArgument>(Add<HConstant>(constant_properties)); 4368 Add<HPushArgument>(Add<HConstant>(constant_properties));
4365 Add<HPushArgument>(Add<HConstant>(flags)); 4369 Add<HPushArgument>(Add<HConstant>(flags));
4366 4370
4371 // TODO(mvstanton): Add a flag to turn off creation of any
4372 // AllocationMementos for this call: we are in crankshaft and should have
4373 // learned enough about transition behavior to stop emitting mementos.
4367 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; 4374 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral;
4368 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), 4375 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
4369 Runtime::FunctionForId(function_id), 4376 Runtime::FunctionForId(function_id),
4370 4); 4377 4);
4371 } 4378 }
4372 4379
4373 // The object is expected in the bailout environment during computation 4380 // The object is expected in the bailout environment during computation
4374 // of the property values and is the value of the entire expression. 4381 // of the property values and is the value of the entire expression.
4375 Push(literal); 4382 Push(literal);
4376 4383
(...skipping 70 matching lines...)
4447 ASSERT(current_block()->HasPredecessor()); 4454 ASSERT(current_block()->HasPredecessor());
4448 ZoneList<Expression*>* subexprs = expr->values(); 4455 ZoneList<Expression*>* subexprs = expr->values();
4449 int length = subexprs->length(); 4456 int length = subexprs->length();
4450 HInstruction* literal; 4457 HInstruction* literal;
4451 4458
4452 Handle<AllocationSite> site; 4459 Handle<AllocationSite> site;
4453 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); 4460 Handle<FixedArray> literals(environment()->closure()->literals(), isolate());
4454 bool uninitialized = false; 4461 bool uninitialized = false;
4455 Handle<Object> literals_cell(literals->get(expr->literal_index()), 4462 Handle<Object> literals_cell(literals->get(expr->literal_index()),
4456 isolate()); 4463 isolate());
4457 Handle<Object> raw_boilerplate; 4464 Handle<JSObject> boilerplate_object;
4458 if (literals_cell->IsUndefined()) { 4465 if (literals_cell->IsUndefined()) {
4459 uninitialized = true; 4466 uninitialized = true;
4460 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( 4467 Handle<Object> raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate(
4461 isolate(), literals, expr->constant_elements()); 4468 isolate(), literals, expr->constant_elements());
4462 if (raw_boilerplate.is_null()) { 4469 if (raw_boilerplate.is_null()) {
4463 return Bailout(kArrayBoilerplateCreationFailed); 4470 return Bailout(kArrayBoilerplateCreationFailed);
4464 } 4471 }
4465 4472
4466 site = isolate()->factory()->NewAllocationSite(); 4473 boilerplate_object = Handle<JSObject>::cast(raw_boilerplate);
4467 site->set_transition_info(*raw_boilerplate); 4474 AllocationSiteCreationContext creation_context(isolate());
4475 site = creation_context.EnterNewScope();
4476 JSObject::DeepWalk(boilerplate_object, &creation_context);
4477 creation_context.ExitScope(site, boilerplate_object);
4468 literals->set(expr->literal_index(), *site); 4478 literals->set(expr->literal_index(), *site);
4469 4479
4470 if (JSObject::cast(*raw_boilerplate)->elements()->map() == 4480 if (boilerplate_object->elements()->map() ==
4471 isolate()->heap()->fixed_cow_array_map()) { 4481 isolate()->heap()->fixed_cow_array_map()) {
4472 isolate()->counters()->cow_arrays_created_runtime()->Increment(); 4482 isolate()->counters()->cow_arrays_created_runtime()->Increment();
4473 } 4483 }
4474 } else { 4484 } else {
4475 ASSERT(literals_cell->IsAllocationSite()); 4485 ASSERT(literals_cell->IsAllocationSite());
4476 site = Handle<AllocationSite>::cast(literals_cell); 4486 site = Handle<AllocationSite>::cast(literals_cell);
4477 raw_boilerplate = Handle<Object>(site->transition_info(), isolate()); 4487 boilerplate_object = Handle<JSObject>(
4488 JSObject::cast(site->transition_info()), isolate());
4478 } 4489 }
4479 4490
4480 ASSERT(!raw_boilerplate.is_null()); 4491 ASSERT(!boilerplate_object.is_null());
4481 ASSERT(site->IsLiteralSite()); 4492 ASSERT(site->SitePointsToLiteral());
4482 4493
4483 Handle<JSObject> boilerplate_object =
4484 Handle<JSObject>::cast(raw_boilerplate);
4485 ElementsKind boilerplate_elements_kind = 4494 ElementsKind boilerplate_elements_kind =
4486 Handle<JSObject>::cast(boilerplate_object)->GetElementsKind(); 4495 boilerplate_object->GetElementsKind();
4487
4488 ASSERT(AllocationSite::CanTrack(boilerplate_object->map()->instance_type()));
4489 4496
4490 // Check whether to use fast or slow deep-copying for boilerplate. 4497 // Check whether to use fast or slow deep-copying for boilerplate.
4491 int max_properties = kMaxFastLiteralProperties; 4498 int max_properties = kMaxFastLiteralProperties;
4492 if (IsFastLiteral(boilerplate_object, 4499 if (IsFastLiteral(boilerplate_object,
4493 kMaxFastLiteralDepth, 4500 kMaxFastLiteralDepth,
4494 &max_properties)) { 4501 &max_properties)) {
4495 literal = BuildFastLiteral(boilerplate_object); 4502 AllocationSiteUsageContext usage_context(isolate(), site, false);
4503 usage_context.EnterNewScope();
4504 literal = BuildFastLiteral(boilerplate_object, &usage_context);
4505 usage_context.ExitScope(site, boilerplate_object);
4496 } else { 4506 } else {
4497 NoObservableSideEffectsScope no_effects(this); 4507 NoObservableSideEffectsScope no_effects(this);
4498 // Boilerplate already exists and constant elements are never accessed, 4508 // Boilerplate already exists and constant elements are never accessed,
4499 // pass an empty fixed array to the runtime function instead. 4509 // pass an empty fixed array to the runtime function instead.
4500 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); 4510 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
4501 int literal_index = expr->literal_index(); 4511 int literal_index = expr->literal_index();
4502 4512
4503 Add<HPushArgument>(Add<HConstant>(literals)); 4513 Add<HPushArgument>(Add<HConstant>(literals));
4504 Add<HPushArgument>(Add<HConstant>(literal_index)); 4514 Add<HPushArgument>(Add<HConstant>(literal_index));
4505 Add<HPushArgument>(Add<HConstant>(constants)); 4515 Add<HPushArgument>(Add<HConstant>(constants));
4506 4516
4517 // TODO(mvstanton): Consider a flag to turn off creation of any
4518 // AllocationMementos for this call: we are in crankshaft and should have
4519 // learned enough about transition behavior to stop emitting mementos.
4507 Runtime::FunctionId function_id = (expr->depth() > 1) 4520 Runtime::FunctionId function_id = (expr->depth() > 1)
4508 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow; 4521 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow;
4509 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), 4522 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
4510 Runtime::FunctionForId(function_id), 4523 Runtime::FunctionForId(function_id),
4511 3); 4524 3);
4512 4525
4513 // De-opt if elements kind changed from boilerplate_elements_kind. 4526 // De-opt if elements kind changed from boilerplate_elements_kind.
4514 Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate()); 4527 Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate());
4515 literal = Add<HCheckMaps>(literal, map, top_info()); 4528 literal = Add<HCheckMaps>(literal, map, top_info());
4516 } 4529 }
(...skipping 3889 matching lines...)
8406 if (function_state()->outer() != NULL) { 8419 if (function_state()->outer() != NULL) {
8407 return New<HConstant>( 8420 return New<HConstant>(
8408 function_state()->compilation_info()->closure()); 8421 function_state()->compilation_info()->closure());
8409 } else { 8422 } else {
8410 return new(zone()) HThisFunction; 8423 return new(zone()) HThisFunction;
8411 } 8424 }
8412 } 8425 }
8413 8426
8414 8427
8415 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( 8428 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
8416 Handle<JSObject> boilerplate_object) { 8429 Handle<JSObject> boilerplate_object,
8430 AllocationSiteContext* site_context) {
8417 NoObservableSideEffectsScope no_effects(this); 8431 NoObservableSideEffectsScope no_effects(this);
8418 InstanceType instance_type = boilerplate_object->map()->instance_type(); 8432 InstanceType instance_type = boilerplate_object->map()->instance_type();
8419 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); 8433 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
8420 8434
8421 HType type = instance_type == JS_ARRAY_TYPE 8435 HType type = instance_type == JS_ARRAY_TYPE
8422 ? HType::JSArray() : HType::JSObject(); 8436 ? HType::JSArray() : HType::JSObject();
8423 HValue* object_size_constant = Add<HConstant>( 8437 HValue* object_size_constant = Add<HConstant>(
8424 boilerplate_object->map()->instance_size()); 8438 boilerplate_object->map()->instance_size());
8425 HInstruction* object = Add<HAllocate>(object_size_constant, type, 8439 HInstruction* object = Add<HAllocate>(object_size_constant, type,
8426 isolate()->heap()->GetPretenureMode(), instance_type); 8440 isolate()->heap()->GetPretenureMode(), instance_type);
(...skipping 11 matching lines...)
8438 if (boilerplate_object->HasFastDoubleElements()) { 8452 if (boilerplate_object->HasFastDoubleElements()) {
8439 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 8453 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
8440 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); 8454 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE);
8441 } else { 8455 } else {
8442 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 8456 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
8443 isolate()->heap()->GetPretenureMode(), FIXED_ARRAY_TYPE); 8457 isolate()->heap()->GetPretenureMode(), FIXED_ARRAY_TYPE);
8444 } 8458 }
8445 } 8459 }
8446 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); 8460 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
8447 8461
8448
8449 // Copy object elements if non-COW. 8462 // Copy object elements if non-COW.
8450 if (object_elements != NULL) { 8463 if (object_elements != NULL) {
8451 BuildEmitElements(boilerplate_object, elements, object_elements); 8464 BuildEmitElements(boilerplate_object, elements, object_elements,
8465 site_context);
8452 } 8466 }
8453 8467
8454 // Copy in-object properties. 8468 // Copy in-object properties.
8455 if (boilerplate_object->map()->NumberOfFields() != 0) { 8469 if (boilerplate_object->map()->NumberOfFields() != 0) {
8456 BuildEmitInObjectProperties(boilerplate_object, object); 8470 BuildEmitInObjectProperties(boilerplate_object, object, site_context);
8457 } 8471 }
8458 return object; 8472 return object;
8459 } 8473 }
8460 8474
8461 8475
8462 void HOptimizedGraphBuilder::BuildEmitObjectHeader( 8476 void HOptimizedGraphBuilder::BuildEmitObjectHeader(
8463 Handle<JSObject> boilerplate_object, 8477 Handle<JSObject> boilerplate_object,
8464 HInstruction* object) { 8478 HInstruction* object) {
8465 ASSERT(boilerplate_object->properties()->length() == 0); 8479 ASSERT(boilerplate_object->properties()->length() == 0);
8466 8480
(...skipping 31 matching lines...)
8498 Handle<Object>(boilerplate_object->elements(), isolate()); 8512 Handle<Object>(boilerplate_object->elements(), isolate());
8499 object_elements = Add<HConstant>(elements_field); 8513 object_elements = Add<HConstant>(elements_field);
8500 } 8514 }
8501 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 8515 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
8502 object_elements); 8516 object_elements);
8503 } 8517 }
8504 8518
8505 8519
8506 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( 8520 void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
8507 Handle<JSObject> boilerplate_object, 8521 Handle<JSObject> boilerplate_object,
8508 HInstruction* object) { 8522 HInstruction* object,
8523 AllocationSiteContext* site_context) {
8509 Handle<DescriptorArray> descriptors( 8524 Handle<DescriptorArray> descriptors(
8510 boilerplate_object->map()->instance_descriptors()); 8525 boilerplate_object->map()->instance_descriptors());
8511 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); 8526 int limit = boilerplate_object->map()->NumberOfOwnDescriptors();
8512 8527
8513 int copied_fields = 0; 8528 int copied_fields = 0;
8514 for (int i = 0; i < limit; i++) { 8529 for (int i = 0; i < limit; i++) {
8515 PropertyDetails details = descriptors->GetDetails(i); 8530 PropertyDetails details = descriptors->GetDetails(i);
8516 if (details.type() != FIELD) continue; 8531 if (details.type() != FIELD) continue;
8517 copied_fields++; 8532 copied_fields++;
8518 int index = descriptors->GetFieldIndex(i); 8533 int index = descriptors->GetFieldIndex(i);
8519 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); 8534 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index);
8520 Handle<Name> name(descriptors->GetKey(i)); 8535 Handle<Name> name(descriptors->GetKey(i));
8521 Handle<Object> value = 8536 Handle<Object> value =
8522 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), 8537 Handle<Object>(boilerplate_object->InObjectPropertyAt(index),
8523 isolate()); 8538 isolate());
8524 8539
8525 // The access for the store depends on the type of the boilerplate. 8540 // The access for the store depends on the type of the boilerplate.
8526 HObjectAccess access = boilerplate_object->IsJSArray() ? 8541 HObjectAccess access = boilerplate_object->IsJSArray() ?
8527 HObjectAccess::ForJSArrayOffset(property_offset) : 8542 HObjectAccess::ForJSArrayOffset(property_offset) :
8528 HObjectAccess::ForJSObjectOffset(property_offset); 8543 HObjectAccess::ForJSObjectOffset(property_offset);
8529 8544
8530 if (value->IsJSObject()) { 8545 if (value->IsJSObject()) {
8531 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 8546 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
8532 HInstruction* result = BuildFastLiteral(value_object); 8547 Handle<AllocationSite> current_site = site_context->EnterNewScope();
8548 HInstruction* result =
8549 BuildFastLiteral(value_object, site_context);
8550 site_context->ExitScope(current_site, value_object);
8533 Add<HStoreNamedField>(object, access, result); 8551 Add<HStoreNamedField>(object, access, result);
8534 } else { 8552 } else {
8535 Representation representation = details.representation(); 8553 Representation representation = details.representation();
8536 HInstruction* value_instruction = Add<HConstant>(value); 8554 HInstruction* value_instruction = Add<HConstant>(value);
8537 8555
8538 if (representation.IsDouble()) { 8556 if (representation.IsDouble()) {
8539 // Allocate a HeapNumber box and store the value into it. 8557 // Allocate a HeapNumber box and store the value into it.
8540 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 8558 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
8559 // TODO(mvstanton): This heap number alloc does not have a corresponding
8560 // AllocationSite. That is okay because
8561 // 1) it's a child object of another object with a valid allocation site
8562 // 2) we can just use the mode of the parent object for pretenuring
8563 // The todo is replace GetPretenureMode() with
8564 // site_context->top()->GetPretenureMode().
8541 HInstruction* double_box = 8565 HInstruction* double_box =
8542 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 8566 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
8543 isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE); 8567 isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE);
8544 AddStoreMapConstant(double_box, 8568 AddStoreMapConstant(double_box,
8545 isolate()->factory()->heap_number_map()); 8569 isolate()->factory()->heap_number_map());
8546 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), 8570 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
8547 value_instruction); 8571 value_instruction);
8548 value_instruction = double_box; 8572 value_instruction = double_box;
8549 } 8573 }
8550 8574
8551 Add<HStoreNamedField>(object, access, value_instruction); 8575 Add<HStoreNamedField>(object, access, value_instruction);
8552 } 8576 }
8553 } 8577 }
8554 8578
8555 int inobject_properties = boilerplate_object->map()->inobject_properties(); 8579 int inobject_properties = boilerplate_object->map()->inobject_properties();
8556 HInstruction* value_instruction = 8580 HInstruction* value_instruction =
8557 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); 8581 Add<HConstant>(isolate()->factory()->one_pointer_filler_map());
8558 for (int i = copied_fields; i < inobject_properties; i++) { 8582 for (int i = copied_fields; i < inobject_properties; i++) {
8559 ASSERT(boilerplate_object->IsJSObject()); 8583 ASSERT(boilerplate_object->IsJSObject());
8560 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); 8584 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
8561 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); 8585 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset);
8562 Add<HStoreNamedField>(object, access, value_instruction); 8586 Add<HStoreNamedField>(object, access, value_instruction);
8563 } 8587 }
8564 } 8588 }
8565 8589
8566 8590
8567 void HOptimizedGraphBuilder::BuildEmitElements( 8591 void HOptimizedGraphBuilder::BuildEmitElements(
8568 Handle<JSObject> boilerplate_object, 8592 Handle<JSObject> boilerplate_object,
8569 Handle<FixedArrayBase> elements, 8593 Handle<FixedArrayBase> elements,
8570 HValue* object_elements) { 8594 HValue* object_elements,
8595 AllocationSiteContext* site_context) {
8571 ElementsKind kind = boilerplate_object->map()->elements_kind(); 8596 ElementsKind kind = boilerplate_object->map()->elements_kind();
8572 int elements_length = elements->length(); 8597 int elements_length = elements->length();
8573 HValue* object_elements_length = Add<HConstant>(elements_length); 8598 HValue* object_elements_length = Add<HConstant>(elements_length);
8574 BuildInitializeElementsHeader(object_elements, kind, object_elements_length); 8599 BuildInitializeElementsHeader(object_elements, kind, object_elements_length);
8575 8600
8576 // Copy elements backing store content. 8601 // Copy elements backing store content.
8577 if (elements->IsFixedDoubleArray()) { 8602 if (elements->IsFixedDoubleArray()) {
8578 BuildEmitFixedDoubleArray(elements, kind, object_elements); 8603 BuildEmitFixedDoubleArray(elements, kind, object_elements);
8579 } else if (elements->IsFixedArray()) { 8604 } else if (elements->IsFixedArray()) {
8580 BuildEmitFixedArray(elements, kind, object_elements); 8605 BuildEmitFixedArray(elements, kind, object_elements,
8606 site_context);
8581 } else { 8607 } else {
8582 UNREACHABLE(); 8608 UNREACHABLE();
8583 } 8609 }
8584 } 8610 }
8585 8611
8586 8612
8587 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray( 8613 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray(
8588 Handle<FixedArrayBase> elements, 8614 Handle<FixedArrayBase> elements,
8589 ElementsKind kind, 8615 ElementsKind kind,
8590 HValue* object_elements) { 8616 HValue* object_elements) {
8591 HInstruction* boilerplate_elements = Add<HConstant>(elements); 8617 HInstruction* boilerplate_elements = Add<HConstant>(elements);
8592 int elements_length = elements->length(); 8618 int elements_length = elements->length();
8593 for (int i = 0; i < elements_length; i++) { 8619 for (int i = 0; i < elements_length; i++) {
8594 HValue* key_constant = Add<HConstant>(i); 8620 HValue* key_constant = Add<HConstant>(i);
8595 HInstruction* value_instruction = 8621 HInstruction* value_instruction =
8596 Add<HLoadKeyed>(boilerplate_elements, key_constant, 8622 Add<HLoadKeyed>(boilerplate_elements, key_constant,
8597 static_cast<HValue*>(NULL), kind, 8623 static_cast<HValue*>(NULL), kind,
8598 ALLOW_RETURN_HOLE); 8624 ALLOW_RETURN_HOLE);
8599 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, 8625 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant,
8600 value_instruction, kind); 8626 value_instruction, kind);
8601 store->SetFlag(HValue::kAllowUndefinedAsNaN); 8627 store->SetFlag(HValue::kAllowUndefinedAsNaN);
8602 } 8628 }
8603 } 8629 }
8604 8630
8605 8631
8606 void HOptimizedGraphBuilder::BuildEmitFixedArray( 8632 void HOptimizedGraphBuilder::BuildEmitFixedArray(
8607 Handle<FixedArrayBase> elements, 8633 Handle<FixedArrayBase> elements,
8608 ElementsKind kind, 8634 ElementsKind kind,
8609 HValue* object_elements) { 8635 HValue* object_elements,
8636 AllocationSiteContext* site_context) {
8610 HInstruction* boilerplate_elements = Add<HConstant>(elements); 8637 HInstruction* boilerplate_elements = Add<HConstant>(elements);
8611 int elements_length = elements->length(); 8638 int elements_length = elements->length();
8612 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 8639 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
8613 for (int i = 0; i < elements_length; i++) { 8640 for (int i = 0; i < elements_length; i++) {
8614 Handle<Object> value(fast_elements->get(i), isolate()); 8641 Handle<Object> value(fast_elements->get(i), isolate());
8615 HValue* key_constant = Add<HConstant>(i); 8642 HValue* key_constant = Add<HConstant>(i);
8616 if (value->IsJSObject()) { 8643 if (value->IsJSObject()) {
8617 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 8644 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
8618 HInstruction* result = BuildFastLiteral(value_object); 8645 Handle<AllocationSite> current_site = site_context->EnterNewScope();
8646 HInstruction* result =
8647 BuildFastLiteral(value_object, site_context);
8648 site_context->ExitScope(current_site, value_object);
8619 Add<HStoreKeyed>(object_elements, key_constant, result, kind); 8649 Add<HStoreKeyed>(object_elements, key_constant, result, kind);
8620 } else { 8650 } else {
8621 HInstruction* value_instruction = 8651 HInstruction* value_instruction =
8622 Add<HLoadKeyed>(boilerplate_elements, key_constant, 8652 Add<HLoadKeyed>(boilerplate_elements, key_constant,
8623 static_cast<HValue*>(NULL), kind, 8653 static_cast<HValue*>(NULL), kind,
8624 ALLOW_RETURN_HOLE); 8654 ALLOW_RETURN_HOLE);
8625 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); 8655 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind);
8626 } 8656 }
8627 } 8657 }
8628 } 8658 }
(...skipping 1251 matching lines...)
9880 if (ShouldProduceTraceOutput()) { 9910 if (ShouldProduceTraceOutput()) {
9881 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9911 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9882 } 9912 }
9883 9913
9884 #ifdef DEBUG 9914 #ifdef DEBUG
9885 graph_->Verify(false); // No full verify. 9915 graph_->Verify(false); // No full verify.
9886 #endif 9916 #endif
9887 } 9917 }
9888 9918
9889 } } // namespace v8::internal 9919 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine