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

Side by Side Diff: src/hydrogen.cc

Issue 25146007: Don't create mementos for shallow SMI array literals in crankshaft (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comments 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') | no next file » | 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 4303 matching lines...) Expand 10 before | Expand all | Expand 10 after
4314 // Check whether to use fast or slow deep-copying for boilerplate. 4314 // Check whether to use fast or slow deep-copying for boilerplate.
4315 int max_properties = kMaxFastLiteralProperties; 4315 int max_properties = kMaxFastLiteralProperties;
4316 Handle<Object> boilerplate(closure->literals()->get( 4316 Handle<Object> boilerplate(closure->literals()->get(
4317 expr->literal_index()), isolate()); 4317 expr->literal_index()), isolate());
4318 if (boilerplate->IsJSObject() && 4318 if (boilerplate->IsJSObject() &&
4319 IsFastLiteral(Handle<JSObject>::cast(boilerplate), 4319 IsFastLiteral(Handle<JSObject>::cast(boilerplate),
4320 kMaxFastLiteralDepth, 4320 kMaxFastLiteralDepth,
4321 &max_properties)) { 4321 &max_properties)) {
4322 Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate); 4322 Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate);
4323 4323
4324 literal = BuildFastLiteral(boilerplate_object, 4324 literal = BuildFastLiteral(boilerplate_object);
4325 Handle<Object>::null(),
4326 DONT_TRACK_ALLOCATION_SITE);
4327 } else { 4325 } else {
4328 NoObservableSideEffectsScope no_effects(this); 4326 NoObservableSideEffectsScope no_effects(this);
4329 Handle<FixedArray> closure_literals(closure->literals(), isolate()); 4327 Handle<FixedArray> closure_literals(closure->literals(), isolate());
4330 Handle<FixedArray> constant_properties = expr->constant_properties(); 4328 Handle<FixedArray> constant_properties = expr->constant_properties();
4331 int literal_index = expr->literal_index(); 4329 int literal_index = expr->literal_index();
4332 int flags = expr->fast_elements() 4330 int flags = expr->fast_elements()
4333 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; 4331 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags;
4334 flags |= expr->has_function() 4332 flags |= expr->has_function()
4335 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; 4333 ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
4336 4334
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4460 ElementsKind boilerplate_elements_kind = 4458 ElementsKind boilerplate_elements_kind =
4461 Handle<JSObject>::cast(boilerplate_object)->GetElementsKind(); 4459 Handle<JSObject>::cast(boilerplate_object)->GetElementsKind();
4462 4460
4463 ASSERT(AllocationSite::CanTrack(boilerplate_object->map()->instance_type())); 4461 ASSERT(AllocationSite::CanTrack(boilerplate_object->map()->instance_type()));
4464 4462
4465 // Check whether to use fast or slow deep-copying for boilerplate. 4463 // Check whether to use fast or slow deep-copying for boilerplate.
4466 int max_properties = kMaxFastLiteralProperties; 4464 int max_properties = kMaxFastLiteralProperties;
4467 if (IsFastLiteral(boilerplate_object, 4465 if (IsFastLiteral(boilerplate_object,
4468 kMaxFastLiteralDepth, 4466 kMaxFastLiteralDepth,
4469 &max_properties)) { 4467 &max_properties)) {
4470 // TODO(mvstanton): This heuristic is only a temporary solution. In the 4468 literal = BuildFastLiteral(boilerplate_object);
4471 // end, we want to quit creating allocation site info after a certain number
4472 // of GCs for a call site.
4473 AllocationSiteMode mode = AllocationSite::GetMode(
4474 boilerplate_elements_kind);
4475
4476 // it doesn't make sense to create allocation mementos if we are going to
4477 // create in old space.
4478 if (mode == TRACK_ALLOCATION_SITE &&
4479 isolate()->heap()->GetPretenureMode() == TENURED) {
4480 mode = DONT_TRACK_ALLOCATION_SITE;
4481 }
4482
4483 literal = BuildFastLiteral(boilerplate_object,
4484 site,
4485 mode);
4486 } else { 4469 } else {
4487 NoObservableSideEffectsScope no_effects(this); 4470 NoObservableSideEffectsScope no_effects(this);
4488 // Boilerplate already exists and constant elements are never accessed, 4471 // Boilerplate already exists and constant elements are never accessed,
4489 // pass an empty fixed array to the runtime function instead. 4472 // pass an empty fixed array to the runtime function instead.
4490 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); 4473 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
4491 int literal_index = expr->literal_index(); 4474 int literal_index = expr->literal_index();
4492 4475
4493 Add<HPushArgument>(Add<HConstant>(literals)); 4476 Add<HPushArgument>(Add<HConstant>(literals));
4494 Add<HPushArgument>(Add<HConstant>(literal_index)); 4477 Add<HPushArgument>(Add<HConstant>(literal_index));
4495 Add<HPushArgument>(Add<HConstant>(constants)); 4478 Add<HPushArgument>(Add<HConstant>(constants));
(...skipping 3876 matching lines...) Expand 10 before | Expand all | Expand 10 after
8372 if (function_state()->outer() != NULL) { 8355 if (function_state()->outer() != NULL) {
8373 return New<HConstant>( 8356 return New<HConstant>(
8374 function_state()->compilation_info()->closure()); 8357 function_state()->compilation_info()->closure());
8375 } else { 8358 } else {
8376 return new(zone()) HThisFunction; 8359 return new(zone()) HThisFunction;
8377 } 8360 }
8378 } 8361 }
8379 8362
8380 8363
8381 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( 8364 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
8382 Handle<JSObject> boilerplate_object, 8365 Handle<JSObject> boilerplate_object) {
8383 Handle<Object> allocation_site_object,
8384 AllocationSiteMode mode) {
8385 NoObservableSideEffectsScope no_effects(this); 8366 NoObservableSideEffectsScope no_effects(this);
8367 InstanceType instance_type = boilerplate_object->map()->instance_type();
8368 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
8386 8369
8387 Handle<FixedArrayBase> elements(boilerplate_object->elements());
8388 int object_size = boilerplate_object->map()->instance_size();
8389 int object_offset = object_size;
8390
8391 InstanceType instance_type = boilerplate_object->map()->instance_type();
8392 bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE;
8393
8394 // If using allocation sites, then
8395 // 1) the payload on the site should already be filled in as a valid
8396 // (boilerplate) array, and
8397 // 2) we shouldn't be pretenuring the allocations.
8398 ASSERT(!create_allocation_site_info ||
8399 (AllocationSite::cast(*allocation_site_object)->IsLiteralSite() &&
8400 isolate()->heap()->GetPretenureMode() == NOT_TENURED));
8401
8402 if (create_allocation_site_info) {
8403 object_size += AllocationMemento::kSize;
8404 }
8405
8406 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
8407 HType type = instance_type == JS_ARRAY_TYPE 8370 HType type = instance_type == JS_ARRAY_TYPE
8408 ? HType::JSArray() : HType::JSObject(); 8371 ? HType::JSArray() : HType::JSObject();
8409 HValue* object_size_constant = Add<HConstant>(object_size); 8372 HValue* object_size_constant = Add<HConstant>(
8373 boilerplate_object->map()->instance_size());
8410 HInstruction* object = Add<HAllocate>(object_size_constant, type, 8374 HInstruction* object = Add<HAllocate>(object_size_constant, type,
8411 isolate()->heap()->GetPretenureMode(), instance_type); 8375 isolate()->heap()->GetPretenureMode(), instance_type);
8412 8376
8413 BuildEmitObjectHeader(boilerplate_object, object); 8377 BuildEmitObjectHeader(boilerplate_object, object);
8414 8378
8415 if (create_allocation_site_info) { 8379 Handle<FixedArrayBase> elements(boilerplate_object->elements());
8416 HInstruction* allocation_site = Add<HConstant>(allocation_site_object);
8417 BuildCreateAllocationMemento(object, object_offset, allocation_site);
8418 }
8419
8420 int elements_size = (elements->length() > 0 && 8380 int elements_size = (elements->length() > 0 &&
8421 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? 8381 elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
8422 elements->Size() : 0; 8382 elements->Size() : 0;
8423 8383
8424 HInstruction* object_elements = NULL; 8384 HInstruction* object_elements = NULL;
8425 if (elements_size > 0) { 8385 if (elements_size > 0) {
8426 HValue* object_elements_size = Add<HConstant>(elements_size); 8386 HValue* object_elements_size = Add<HConstant>(elements_size);
8427 if (boilerplate_object->HasFastDoubleElements()) { 8387 if (boilerplate_object->HasFastDoubleElements()) {
8428 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 8388 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
8429 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); 8389 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
8511 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), 8471 Handle<Object>(boilerplate_object->InObjectPropertyAt(index),
8512 isolate()); 8472 isolate());
8513 8473
8514 // The access for the store depends on the type of the boilerplate. 8474 // The access for the store depends on the type of the boilerplate.
8515 HObjectAccess access = boilerplate_object->IsJSArray() ? 8475 HObjectAccess access = boilerplate_object->IsJSArray() ?
8516 HObjectAccess::ForJSArrayOffset(property_offset) : 8476 HObjectAccess::ForJSArrayOffset(property_offset) :
8517 HObjectAccess::ForJSObjectOffset(property_offset); 8477 HObjectAccess::ForJSObjectOffset(property_offset);
8518 8478
8519 if (value->IsJSObject()) { 8479 if (value->IsJSObject()) {
8520 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 8480 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
8521 HInstruction* result = 8481 HInstruction* result = BuildFastLiteral(value_object);
8522 BuildFastLiteral(value_object,
8523 Handle<Object>::null(), DONT_TRACK_ALLOCATION_SITE);
8524 Add<HStoreNamedField>(object, access, result); 8482 Add<HStoreNamedField>(object, access, result);
8525 } else { 8483 } else {
8526 Representation representation = details.representation(); 8484 Representation representation = details.representation();
8527 HInstruction* value_instruction = Add<HConstant>(value); 8485 HInstruction* value_instruction = Add<HConstant>(value);
8528 8486
8529 if (representation.IsDouble()) { 8487 if (representation.IsDouble()) {
8530 // Allocate a HeapNumber box and store the value into it. 8488 // Allocate a HeapNumber box and store the value into it.
8531 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 8489 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
8532 HInstruction* double_box = 8490 HInstruction* double_box =
8533 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 8491 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
8599 ElementsKind kind, 8557 ElementsKind kind,
8600 HValue* object_elements) { 8558 HValue* object_elements) {
8601 HInstruction* boilerplate_elements = Add<HConstant>(elements); 8559 HInstruction* boilerplate_elements = Add<HConstant>(elements);
8602 int elements_length = elements->length(); 8560 int elements_length = elements->length();
8603 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 8561 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
8604 for (int i = 0; i < elements_length; i++) { 8562 for (int i = 0; i < elements_length; i++) {
8605 Handle<Object> value(fast_elements->get(i), isolate()); 8563 Handle<Object> value(fast_elements->get(i), isolate());
8606 HValue* key_constant = Add<HConstant>(i); 8564 HValue* key_constant = Add<HConstant>(i);
8607 if (value->IsJSObject()) { 8565 if (value->IsJSObject()) {
8608 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 8566 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
8609 HInstruction* result = 8567 HInstruction* result = BuildFastLiteral(value_object);
8610 BuildFastLiteral(value_object,
8611 Handle<Object>::null(), DONT_TRACK_ALLOCATION_SITE);
8612 Add<HStoreKeyed>(object_elements, key_constant, result, kind); 8568 Add<HStoreKeyed>(object_elements, key_constant, result, kind);
8613 } else { 8569 } else {
8614 HInstruction* value_instruction = 8570 HInstruction* value_instruction =
8615 Add<HLoadKeyed>(boilerplate_elements, key_constant, 8571 Add<HLoadKeyed>(boilerplate_elements, key_constant,
8616 static_cast<HValue*>(NULL), kind, 8572 static_cast<HValue*>(NULL), kind,
8617 ALLOW_RETURN_HOLE); 8573 ALLOW_RETURN_HOLE);
8618 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); 8574 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind);
8619 } 8575 }
8620 } 8576 }
8621 } 8577 }
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
9873 if (ShouldProduceTraceOutput()) { 9829 if (ShouldProduceTraceOutput()) {
9874 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9830 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9875 } 9831 }
9876 9832
9877 #ifdef DEBUG 9833 #ifdef DEBUG
9878 graph_->Verify(false); // No full verify. 9834 graph_->Verify(false); // No full verify.
9879 #endif 9835 #endif
9880 } 9836 }
9881 9837
9882 } } // namespace v8::internal 9838 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698