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

Side by Side Diff: src/hydrogen.cc

Issue 26539010: Revert "AllocationSites for all literals" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('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 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...) Expand all
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"
34 #include "codegen.h" 33 #include "codegen.h"
35 #include "full-codegen.h" 34 #include "full-codegen.h"
36 #include "hashmap.h" 35 #include "hashmap.h"
37 #include "hydrogen-bce.h" 36 #include "hydrogen-bce.h"
38 #include "hydrogen-bch.h" 37 #include "hydrogen-bch.h"
39 #include "hydrogen-canonicalize.h" 38 #include "hydrogen-canonicalize.h"
40 #include "hydrogen-check-elimination.h" 39 #include "hydrogen-check-elimination.h"
41 #include "hydrogen-dce.h" 40 #include "hydrogen-dce.h"
42 #include "hydrogen-dehoist.h" 41 #include "hydrogen-dehoist.h"
43 #include "hydrogen-environment-liveness.h" 42 #include "hydrogen-environment-liveness.h"
(...skipping 4248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4292 Handle<JSObject> boilerplate; 4291 Handle<JSObject> boilerplate;
4293 if (!literals_cell->IsUndefined()) { 4292 if (!literals_cell->IsUndefined()) {
4294 // Retrieve the boilerplate 4293 // Retrieve the boilerplate
4295 site = Handle<AllocationSite>::cast(literals_cell); 4294 site = Handle<AllocationSite>::cast(literals_cell);
4296 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), 4295 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()),
4297 isolate()); 4296 isolate());
4298 } 4297 }
4299 4298
4300 if (!boilerplate.is_null() && 4299 if (!boilerplate.is_null() &&
4301 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { 4300 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
4302 AllocationSiteUsageContext usage_context(isolate(), site, false); 4301 literal = BuildFastLiteral(boilerplate);
4303 usage_context.EnterNewScope();
4304 literal = BuildFastLiteral(boilerplate, &usage_context);
4305 usage_context.ExitScope(site, boilerplate);
4306 } else { 4302 } else {
4307 NoObservableSideEffectsScope no_effects(this); 4303 NoObservableSideEffectsScope no_effects(this);
4308 Handle<FixedArray> closure_literals(closure->literals(), isolate()); 4304 Handle<FixedArray> closure_literals(closure->literals(), isolate());
4309 Handle<FixedArray> constant_properties = expr->constant_properties(); 4305 Handle<FixedArray> constant_properties = expr->constant_properties();
4310 int literal_index = expr->literal_index(); 4306 int literal_index = expr->literal_index();
4311 int flags = expr->fast_elements() 4307 int flags = expr->fast_elements()
4312 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; 4308 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags;
4313 flags |= expr->has_function() 4309 flags |= expr->has_function()
4314 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; 4310 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
4315 4311
4316 Add<HPushArgument>(Add<HConstant>(closure_literals)); 4312 Add<HPushArgument>(Add<HConstant>(closure_literals));
4317 Add<HPushArgument>(Add<HConstant>(literal_index)); 4313 Add<HPushArgument>(Add<HConstant>(literal_index));
4318 Add<HPushArgument>(Add<HConstant>(constant_properties)); 4314 Add<HPushArgument>(Add<HConstant>(constant_properties));
4319 Add<HPushArgument>(Add<HConstant>(flags)); 4315 Add<HPushArgument>(Add<HConstant>(flags));
4320 4316
4321 // TODO(mvstanton): Add a flag to turn off creation of any
4322 // AllocationMementos for this call: we are in crankshaft and should have
4323 // learned enough about transition behavior to stop emitting mementos.
4324 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; 4317 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral;
4325 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), 4318 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
4326 Runtime::FunctionForId(function_id), 4319 Runtime::FunctionForId(function_id),
4327 4); 4320 4);
4328 } 4321 }
4329 4322
4330 // The object is expected in the bailout environment during computation 4323 // The object is expected in the bailout environment during computation
4331 // of the property values and is the value of the entire expression. 4324 // of the property values and is the value of the entire expression.
4332 Push(literal); 4325 Push(literal);
4333 4326
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4404 ASSERT(current_block()->HasPredecessor()); 4397 ASSERT(current_block()->HasPredecessor());
4405 ZoneList<Expression*>* subexprs = expr->values(); 4398 ZoneList<Expression*>* subexprs = expr->values();
4406 int length = subexprs->length(); 4399 int length = subexprs->length();
4407 HInstruction* literal; 4400 HInstruction* literal;
4408 4401
4409 Handle<AllocationSite> site; 4402 Handle<AllocationSite> site;
4410 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); 4403 Handle<FixedArray> literals(environment()->closure()->literals(), isolate());
4411 bool uninitialized = false; 4404 bool uninitialized = false;
4412 Handle<Object> literals_cell(literals->get(expr->literal_index()), 4405 Handle<Object> literals_cell(literals->get(expr->literal_index()),
4413 isolate()); 4406 isolate());
4414 Handle<JSObject> boilerplate_object; 4407 Handle<Object> raw_boilerplate;
4415 if (literals_cell->IsUndefined()) { 4408 if (literals_cell->IsUndefined()) {
4416 uninitialized = true; 4409 uninitialized = true;
4417 Handle<Object> raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( 4410 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate(
4418 isolate(), literals, expr->constant_elements()); 4411 isolate(), literals, expr->constant_elements());
4419 if (raw_boilerplate.is_null()) { 4412 if (raw_boilerplate.is_null()) {
4420 return Bailout(kArrayBoilerplateCreationFailed); 4413 return Bailout(kArrayBoilerplateCreationFailed);
4421 } 4414 }
4422 4415
4423 boilerplate_object = Handle<JSObject>::cast(raw_boilerplate); 4416 site = isolate()->factory()->NewAllocationSite();
4424 AllocationSiteCreationContext creation_context(isolate()); 4417 site->set_transition_info(*raw_boilerplate);
4425 site = creation_context.EnterNewScope();
4426 JSObject::DeepWalk(boilerplate_object, &creation_context);
4427 creation_context.ExitScope(site, boilerplate_object);
4428 literals->set(expr->literal_index(), *site); 4418 literals->set(expr->literal_index(), *site);
4429 4419
4430 if (boilerplate_object->elements()->map() == 4420 if (JSObject::cast(*raw_boilerplate)->elements()->map() ==
4431 isolate()->heap()->fixed_cow_array_map()) { 4421 isolate()->heap()->fixed_cow_array_map()) {
4432 isolate()->counters()->cow_arrays_created_runtime()->Increment(); 4422 isolate()->counters()->cow_arrays_created_runtime()->Increment();
4433 } 4423 }
4434 } else { 4424 } else {
4435 ASSERT(literals_cell->IsAllocationSite()); 4425 ASSERT(literals_cell->IsAllocationSite());
4436 site = Handle<AllocationSite>::cast(literals_cell); 4426 site = Handle<AllocationSite>::cast(literals_cell);
4437 boilerplate_object = Handle<JSObject>( 4427 raw_boilerplate = Handle<Object>(site->transition_info(), isolate());
4438 JSObject::cast(site->transition_info()), isolate());
4439 } 4428 }
4440 4429
4441 ASSERT(!boilerplate_object.is_null()); 4430 ASSERT(!raw_boilerplate.is_null());
4442 ASSERT(site->SitePointsToLiteral()); 4431 ASSERT(site->IsLiteralSite());
4443 4432
4433 Handle<JSObject> boilerplate_object =
4434 Handle<JSObject>::cast(raw_boilerplate);
4444 ElementsKind boilerplate_elements_kind = 4435 ElementsKind boilerplate_elements_kind =
4445 boilerplate_object->GetElementsKind(); 4436 Handle<JSObject>::cast(boilerplate_object)->GetElementsKind();
4437
4438 ASSERT(AllocationSite::CanTrack(boilerplate_object->map()->instance_type()));
4446 4439
4447 // Check whether to use fast or slow deep-copying for boilerplate. 4440 // Check whether to use fast or slow deep-copying for boilerplate.
4448 int max_properties = kMaxFastLiteralProperties; 4441 int max_properties = kMaxFastLiteralProperties;
4449 if (IsFastLiteral(boilerplate_object, 4442 if (IsFastLiteral(boilerplate_object,
4450 kMaxFastLiteralDepth, 4443 kMaxFastLiteralDepth,
4451 &max_properties)) { 4444 &max_properties)) {
4452 AllocationSiteUsageContext usage_context(isolate(), site, false); 4445 literal = BuildFastLiteral(boilerplate_object);
4453 usage_context.EnterNewScope();
4454 literal = BuildFastLiteral(boilerplate_object, &usage_context);
4455 usage_context.ExitScope(site, boilerplate_object);
4456 } else { 4446 } else {
4457 NoObservableSideEffectsScope no_effects(this); 4447 NoObservableSideEffectsScope no_effects(this);
4458 // Boilerplate already exists and constant elements are never accessed, 4448 // Boilerplate already exists and constant elements are never accessed,
4459 // pass an empty fixed array to the runtime function instead. 4449 // pass an empty fixed array to the runtime function instead.
4460 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); 4450 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
4461 int literal_index = expr->literal_index(); 4451 int literal_index = expr->literal_index();
4462 4452
4463 Add<HPushArgument>(Add<HConstant>(literals)); 4453 Add<HPushArgument>(Add<HConstant>(literals));
4464 Add<HPushArgument>(Add<HConstant>(literal_index)); 4454 Add<HPushArgument>(Add<HConstant>(literal_index));
4465 Add<HPushArgument>(Add<HConstant>(constants)); 4455 Add<HPushArgument>(Add<HConstant>(constants));
4466 4456
4467 // TODO(mvstanton): Consider a flag to turn off creation of any
4468 // AllocationMementos for this call: we are in crankshaft and should have
4469 // learned enough about transition behavior to stop emitting mementos.
4470 Runtime::FunctionId function_id = (expr->depth() > 1) 4457 Runtime::FunctionId function_id = (expr->depth() > 1)
4471 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow; 4458 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow;
4472 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), 4459 literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
4473 Runtime::FunctionForId(function_id), 4460 Runtime::FunctionForId(function_id),
4474 3); 4461 3);
4475 4462
4476 // De-opt if elements kind changed from boilerplate_elements_kind. 4463 // De-opt if elements kind changed from boilerplate_elements_kind.
4477 Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate()); 4464 Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate());
4478 literal = Add<HCheckMaps>(literal, map, top_info()); 4465 literal = Add<HCheckMaps>(literal, map, top_info());
4479 } 4466 }
(...skipping 3868 matching lines...) Expand 10 before | Expand all | Expand 10 after
8348 if (function_state()->outer() != NULL) { 8335 if (function_state()->outer() != NULL) {
8349 return New<HConstant>( 8336 return New<HConstant>(
8350 function_state()->compilation_info()->closure()); 8337 function_state()->compilation_info()->closure());
8351 } else { 8338 } else {
8352 return new(zone()) HThisFunction; 8339 return new(zone()) HThisFunction;
8353 } 8340 }
8354 } 8341 }
8355 8342
8356 8343
8357 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( 8344 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
8358 Handle<JSObject> boilerplate_object, 8345 Handle<JSObject> boilerplate_object) {
8359 AllocationSiteContext* site_context) {
8360 NoObservableSideEffectsScope no_effects(this); 8346 NoObservableSideEffectsScope no_effects(this);
8361 InstanceType instance_type = boilerplate_object->map()->instance_type(); 8347 InstanceType instance_type = boilerplate_object->map()->instance_type();
8362 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); 8348 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
8363 8349
8364 HType type = instance_type == JS_ARRAY_TYPE 8350 HType type = instance_type == JS_ARRAY_TYPE
8365 ? HType::JSArray() : HType::JSObject(); 8351 ? HType::JSArray() : HType::JSObject();
8366 HValue* object_size_constant = Add<HConstant>( 8352 HValue* object_size_constant = Add<HConstant>(
8367 boilerplate_object->map()->instance_size()); 8353 boilerplate_object->map()->instance_size());
8368 HInstruction* object = Add<HAllocate>(object_size_constant, type, 8354 HInstruction* object = Add<HAllocate>(object_size_constant, type,
8369 isolate()->heap()->GetPretenureMode(), instance_type); 8355 isolate()->heap()->GetPretenureMode(), instance_type);
(...skipping 11 matching lines...) Expand all
8381 if (boilerplate_object->HasFastDoubleElements()) { 8367 if (boilerplate_object->HasFastDoubleElements()) {
8382 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 8368 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
8383 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); 8369 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE);
8384 } else { 8370 } else {
8385 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 8371 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
8386 isolate()->heap()->GetPretenureMode(), FIXED_ARRAY_TYPE); 8372 isolate()->heap()->GetPretenureMode(), FIXED_ARRAY_TYPE);
8387 } 8373 }
8388 } 8374 }
8389 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); 8375 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
8390 8376
8377
8391 // Copy object elements if non-COW. 8378 // Copy object elements if non-COW.
8392 if (object_elements != NULL) { 8379 if (object_elements != NULL) {
8393 BuildEmitElements(boilerplate_object, elements, object_elements, 8380 BuildEmitElements(boilerplate_object, elements, object_elements);
8394 site_context);
8395 } 8381 }
8396 8382
8397 // Copy in-object properties. 8383 // Copy in-object properties.
8398 if (boilerplate_object->map()->NumberOfFields() != 0) { 8384 if (boilerplate_object->map()->NumberOfFields() != 0) {
8399 BuildEmitInObjectProperties(boilerplate_object, object, site_context); 8385 BuildEmitInObjectProperties(boilerplate_object, object);
8400 } 8386 }
8401 return object; 8387 return object;
8402 } 8388 }
8403 8389
8404 8390
8405 void HOptimizedGraphBuilder::BuildEmitObjectHeader( 8391 void HOptimizedGraphBuilder::BuildEmitObjectHeader(
8406 Handle<JSObject> boilerplate_object, 8392 Handle<JSObject> boilerplate_object,
8407 HInstruction* object) { 8393 HInstruction* object) {
8408 ASSERT(boilerplate_object->properties()->length() == 0); 8394 ASSERT(boilerplate_object->properties()->length() == 0);
8409 8395
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
8441 Handle<Object>(boilerplate_object->elements(), isolate()); 8427 Handle<Object>(boilerplate_object->elements(), isolate());
8442 object_elements = Add<HConstant>(elements_field); 8428 object_elements = Add<HConstant>(elements_field);
8443 } 8429 }
8444 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 8430 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
8445 object_elements); 8431 object_elements);
8446 } 8432 }
8447 8433
8448 8434
8449 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( 8435 void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
8450 Handle<JSObject> boilerplate_object, 8436 Handle<JSObject> boilerplate_object,
8451 HInstruction* object, 8437 HInstruction* object) {
8452 AllocationSiteContext* site_context) {
8453 Handle<DescriptorArray> descriptors( 8438 Handle<DescriptorArray> descriptors(
8454 boilerplate_object->map()->instance_descriptors()); 8439 boilerplate_object->map()->instance_descriptors());
8455 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); 8440 int limit = boilerplate_object->map()->NumberOfOwnDescriptors();
8456 8441
8457 int copied_fields = 0; 8442 int copied_fields = 0;
8458 for (int i = 0; i < limit; i++) { 8443 for (int i = 0; i < limit; i++) {
8459 PropertyDetails details = descriptors->GetDetails(i); 8444 PropertyDetails details = descriptors->GetDetails(i);
8460 if (details.type() != FIELD) continue; 8445 if (details.type() != FIELD) continue;
8461 copied_fields++; 8446 copied_fields++;
8462 int index = descriptors->GetFieldIndex(i); 8447 int index = descriptors->GetFieldIndex(i);
8463 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); 8448 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index);
8464 Handle<Name> name(descriptors->GetKey(i)); 8449 Handle<Name> name(descriptors->GetKey(i));
8465 Handle<Object> value = 8450 Handle<Object> value =
8466 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), 8451 Handle<Object>(boilerplate_object->InObjectPropertyAt(index),
8467 isolate()); 8452 isolate());
8468 8453
8469 // The access for the store depends on the type of the boilerplate. 8454 // The access for the store depends on the type of the boilerplate.
8470 HObjectAccess access = boilerplate_object->IsJSArray() ? 8455 HObjectAccess access = boilerplate_object->IsJSArray() ?
8471 HObjectAccess::ForJSArrayOffset(property_offset) : 8456 HObjectAccess::ForJSArrayOffset(property_offset) :
8472 HObjectAccess::ForJSObjectOffset(property_offset); 8457 HObjectAccess::ForJSObjectOffset(property_offset);
8473 8458
8474 if (value->IsJSObject()) { 8459 if (value->IsJSObject()) {
8475 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 8460 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
8476 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 8461 HInstruction* result = BuildFastLiteral(value_object);
8477 HInstruction* result =
8478 BuildFastLiteral(value_object, site_context);
8479 site_context->ExitScope(current_site, value_object);
8480 Add<HStoreNamedField>(object, access, result); 8462 Add<HStoreNamedField>(object, access, result);
8481 } else { 8463 } else {
8482 Representation representation = details.representation(); 8464 Representation representation = details.representation();
8483 HInstruction* value_instruction = Add<HConstant>(value); 8465 HInstruction* value_instruction = Add<HConstant>(value);
8484 8466
8485 if (representation.IsDouble()) { 8467 if (representation.IsDouble()) {
8486 // Allocate a HeapNumber box and store the value into it. 8468 // Allocate a HeapNumber box and store the value into it.
8487 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 8469 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
8488 // TODO(mvstanton): This heap number alloc does not have a corresponding
8489 // AllocationSite. That is okay because
8490 // 1) it's a child object of another object with a valid allocation site
8491 // 2) we can just use the mode of the parent object for pretenuring
8492 // The todo is replace GetPretenureMode() with
8493 // site_context->top()->GetPretenureMode().
8494 HInstruction* double_box = 8470 HInstruction* double_box =
8495 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 8471 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
8496 isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE); 8472 isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE);
8497 AddStoreMapConstant(double_box, 8473 AddStoreMapConstant(double_box,
8498 isolate()->factory()->heap_number_map()); 8474 isolate()->factory()->heap_number_map());
8499 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), 8475 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
8500 value_instruction); 8476 value_instruction);
8501 value_instruction = double_box; 8477 value_instruction = double_box;
8502 } 8478 }
8503 8479
8504 Add<HStoreNamedField>(object, access, value_instruction); 8480 Add<HStoreNamedField>(object, access, value_instruction);
8505 } 8481 }
8506 } 8482 }
8507 8483
8508 int inobject_properties = boilerplate_object->map()->inobject_properties(); 8484 int inobject_properties = boilerplate_object->map()->inobject_properties();
8509 HInstruction* value_instruction = 8485 HInstruction* value_instruction =
8510 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); 8486 Add<HConstant>(isolate()->factory()->one_pointer_filler_map());
8511 for (int i = copied_fields; i < inobject_properties; i++) { 8487 for (int i = copied_fields; i < inobject_properties; i++) {
8512 ASSERT(boilerplate_object->IsJSObject()); 8488 ASSERT(boilerplate_object->IsJSObject());
8513 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); 8489 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
8514 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); 8490 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset);
8515 Add<HStoreNamedField>(object, access, value_instruction); 8491 Add<HStoreNamedField>(object, access, value_instruction);
8516 } 8492 }
8517 } 8493 }
8518 8494
8519 8495
8520 void HOptimizedGraphBuilder::BuildEmitElements( 8496 void HOptimizedGraphBuilder::BuildEmitElements(
8521 Handle<JSObject> boilerplate_object, 8497 Handle<JSObject> boilerplate_object,
8522 Handle<FixedArrayBase> elements, 8498 Handle<FixedArrayBase> elements,
8523 HValue* object_elements, 8499 HValue* object_elements) {
8524 AllocationSiteContext* site_context) {
8525 ElementsKind kind = boilerplate_object->map()->elements_kind(); 8500 ElementsKind kind = boilerplate_object->map()->elements_kind();
8526 int elements_length = elements->length(); 8501 int elements_length = elements->length();
8527 HValue* object_elements_length = Add<HConstant>(elements_length); 8502 HValue* object_elements_length = Add<HConstant>(elements_length);
8528 BuildInitializeElementsHeader(object_elements, kind, object_elements_length); 8503 BuildInitializeElementsHeader(object_elements, kind, object_elements_length);
8529 8504
8530 // Copy elements backing store content. 8505 // Copy elements backing store content.
8531 if (elements->IsFixedDoubleArray()) { 8506 if (elements->IsFixedDoubleArray()) {
8532 BuildEmitFixedDoubleArray(elements, kind, object_elements); 8507 BuildEmitFixedDoubleArray(elements, kind, object_elements);
8533 } else if (elements->IsFixedArray()) { 8508 } else if (elements->IsFixedArray()) {
8534 BuildEmitFixedArray(elements, kind, object_elements, 8509 BuildEmitFixedArray(elements, kind, object_elements);
8535 site_context);
8536 } else { 8510 } else {
8537 UNREACHABLE(); 8511 UNREACHABLE();
8538 } 8512 }
8539 } 8513 }
8540 8514
8541 8515
8542 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray( 8516 void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray(
8543 Handle<FixedArrayBase> elements, 8517 Handle<FixedArrayBase> elements,
8544 ElementsKind kind, 8518 ElementsKind kind,
8545 HValue* object_elements) { 8519 HValue* object_elements) {
8546 HInstruction* boilerplate_elements = Add<HConstant>(elements); 8520 HInstruction* boilerplate_elements = Add<HConstant>(elements);
8547 int elements_length = elements->length(); 8521 int elements_length = elements->length();
8548 for (int i = 0; i < elements_length; i++) { 8522 for (int i = 0; i < elements_length; i++) {
8549 HValue* key_constant = Add<HConstant>(i); 8523 HValue* key_constant = Add<HConstant>(i);
8550 HInstruction* value_instruction = 8524 HInstruction* value_instruction =
8551 Add<HLoadKeyed>(boilerplate_elements, key_constant, 8525 Add<HLoadKeyed>(boilerplate_elements, key_constant,
8552 static_cast<HValue*>(NULL), kind, 8526 static_cast<HValue*>(NULL), kind,
8553 ALLOW_RETURN_HOLE); 8527 ALLOW_RETURN_HOLE);
8554 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, 8528 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant,
8555 value_instruction, kind); 8529 value_instruction, kind);
8556 store->SetFlag(HValue::kAllowUndefinedAsNaN); 8530 store->SetFlag(HValue::kAllowUndefinedAsNaN);
8557 } 8531 }
8558 } 8532 }
8559 8533
8560 8534
8561 void HOptimizedGraphBuilder::BuildEmitFixedArray( 8535 void HOptimizedGraphBuilder::BuildEmitFixedArray(
8562 Handle<FixedArrayBase> elements, 8536 Handle<FixedArrayBase> elements,
8563 ElementsKind kind, 8537 ElementsKind kind,
8564 HValue* object_elements, 8538 HValue* object_elements) {
8565 AllocationSiteContext* site_context) {
8566 HInstruction* boilerplate_elements = Add<HConstant>(elements); 8539 HInstruction* boilerplate_elements = Add<HConstant>(elements);
8567 int elements_length = elements->length(); 8540 int elements_length = elements->length();
8568 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 8541 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
8569 for (int i = 0; i < elements_length; i++) { 8542 for (int i = 0; i < elements_length; i++) {
8570 Handle<Object> value(fast_elements->get(i), isolate()); 8543 Handle<Object> value(fast_elements->get(i), isolate());
8571 HValue* key_constant = Add<HConstant>(i); 8544 HValue* key_constant = Add<HConstant>(i);
8572 if (value->IsJSObject()) { 8545 if (value->IsJSObject()) {
8573 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 8546 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
8574 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 8547 HInstruction* result = BuildFastLiteral(value_object);
8575 HInstruction* result =
8576 BuildFastLiteral(value_object, site_context);
8577 site_context->ExitScope(current_site, value_object);
8578 Add<HStoreKeyed>(object_elements, key_constant, result, kind); 8548 Add<HStoreKeyed>(object_elements, key_constant, result, kind);
8579 } else { 8549 } else {
8580 HInstruction* value_instruction = 8550 HInstruction* value_instruction =
8581 Add<HLoadKeyed>(boilerplate_elements, key_constant, 8551 Add<HLoadKeyed>(boilerplate_elements, key_constant,
8582 static_cast<HValue*>(NULL), kind, 8552 static_cast<HValue*>(NULL), kind,
8583 ALLOW_RETURN_HOLE); 8553 ALLOW_RETURN_HOLE);
8584 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); 8554 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind);
8585 } 8555 }
8586 } 8556 }
8587 } 8557 }
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
9839 if (ShouldProduceTraceOutput()) { 9809 if (ShouldProduceTraceOutput()) {
9840 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9810 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9841 } 9811 }
9842 9812
9843 #ifdef DEBUG 9813 #ifdef DEBUG
9844 graph_->Verify(false); // No full verify. 9814 graph_->Verify(false); // No full verify.
9845 #endif 9815 #endif
9846 } 9816 }
9847 9817
9848 } } // namespace v8::internal 9818 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698