Chromium Code Reviews| 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 4303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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); |
| 8386 | 8367 |
| 8387 Handle<FixedArrayBase> elements(boilerplate_object->elements()); | 8368 Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
|
Hannes Payer (out of office)
2013/09/30 19:12:52
Since you are already here, could you move element
mvstanton
2013/09/30 20:50:33
Done.
| |
| 8388 int object_size = boilerplate_object->map()->instance_size(); | 8369 int object_size = boilerplate_object->map()->instance_size(); |
|
Hannes Payer (out of office)
2013/09/30 19:12:52
You could delete object_size...
mvstanton
2013/09/30 20:50:33
Done.
| |
| 8389 int object_offset = object_size; | |
| 8390 | |
| 8391 InstanceType instance_type = boilerplate_object->map()->instance_type(); | 8370 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 | 8371 |
| 8406 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); | 8372 ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); |
| 8407 HType type = instance_type == JS_ARRAY_TYPE | 8373 HType type = instance_type == JS_ARRAY_TYPE |
| 8408 ? HType::JSArray() : HType::JSObject(); | 8374 ? HType::JSArray() : HType::JSObject(); |
| 8409 HValue* object_size_constant = Add<HConstant>(object_size); | 8375 HValue* object_size_constant = Add<HConstant>(object_size); |
|
Hannes Payer (out of office)
2013/09/30 19:12:52
and change that line to:
HValue* object_size =
mvstanton
2013/09/30 20:50:33
Done.
| |
| 8410 HInstruction* object = Add<HAllocate>(object_size_constant, type, | 8376 HInstruction* object = Add<HAllocate>(object_size_constant, type, |
| 8411 isolate()->heap()->GetPretenureMode(), instance_type); | 8377 isolate()->heap()->GetPretenureMode(), instance_type); |
| 8412 | 8378 |
| 8413 BuildEmitObjectHeader(boilerplate_object, object); | 8379 BuildEmitObjectHeader(boilerplate_object, object); |
| 8414 | 8380 |
| 8415 if (create_allocation_site_info) { | |
| 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 && | 8381 int elements_size = (elements->length() > 0 && |
| 8421 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? | 8382 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? |
| 8422 elements->Size() : 0; | 8383 elements->Size() : 0; |
| 8423 | 8384 |
| 8424 HInstruction* object_elements = NULL; | 8385 HInstruction* object_elements = NULL; |
| 8425 if (elements_size > 0) { | 8386 if (elements_size > 0) { |
| 8426 HValue* object_elements_size = Add<HConstant>(elements_size); | 8387 HValue* object_elements_size = Add<HConstant>(elements_size); |
| 8427 if (boilerplate_object->HasFastDoubleElements()) { | 8388 if (boilerplate_object->HasFastDoubleElements()) { |
| 8428 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), | 8389 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), |
| 8429 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); | 8390 isolate()->heap()->GetPretenureMode(), FIXED_DOUBLE_ARRAY_TYPE); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8511 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), | 8472 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), |
| 8512 isolate()); | 8473 isolate()); |
| 8513 | 8474 |
| 8514 // The access for the store depends on the type of the boilerplate. | 8475 // The access for the store depends on the type of the boilerplate. |
| 8515 HObjectAccess access = boilerplate_object->IsJSArray() ? | 8476 HObjectAccess access = boilerplate_object->IsJSArray() ? |
| 8516 HObjectAccess::ForJSArrayOffset(property_offset) : | 8477 HObjectAccess::ForJSArrayOffset(property_offset) : |
| 8517 HObjectAccess::ForJSObjectOffset(property_offset); | 8478 HObjectAccess::ForJSObjectOffset(property_offset); |
| 8518 | 8479 |
| 8519 if (value->IsJSObject()) { | 8480 if (value->IsJSObject()) { |
| 8520 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 8481 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 8521 HInstruction* result = | 8482 HInstruction* result = BuildFastLiteral(value_object); |
| 8522 BuildFastLiteral(value_object, | |
| 8523 Handle<Object>::null(), DONT_TRACK_ALLOCATION_SITE); | |
| 8524 Add<HStoreNamedField>(object, access, result); | 8483 Add<HStoreNamedField>(object, access, result); |
| 8525 } else { | 8484 } else { |
| 8526 Representation representation = details.representation(); | 8485 Representation representation = details.representation(); |
| 8527 HInstruction* value_instruction = Add<HConstant>(value); | 8486 HInstruction* value_instruction = Add<HConstant>(value); |
| 8528 | 8487 |
| 8529 if (representation.IsDouble()) { | 8488 if (representation.IsDouble()) { |
| 8530 // Allocate a HeapNumber box and store the value into it. | 8489 // Allocate a HeapNumber box and store the value into it. |
| 8531 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); | 8490 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); |
| 8532 HInstruction* double_box = | 8491 HInstruction* double_box = |
| 8533 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), | 8492 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8599 ElementsKind kind, | 8558 ElementsKind kind, |
| 8600 HValue* object_elements) { | 8559 HValue* object_elements) { |
| 8601 HInstruction* boilerplate_elements = Add<HConstant>(elements); | 8560 HInstruction* boilerplate_elements = Add<HConstant>(elements); |
| 8602 int elements_length = elements->length(); | 8561 int elements_length = elements->length(); |
| 8603 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); | 8562 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); |
| 8604 for (int i = 0; i < elements_length; i++) { | 8563 for (int i = 0; i < elements_length; i++) { |
| 8605 Handle<Object> value(fast_elements->get(i), isolate()); | 8564 Handle<Object> value(fast_elements->get(i), isolate()); |
| 8606 HValue* key_constant = Add<HConstant>(i); | 8565 HValue* key_constant = Add<HConstant>(i); |
| 8607 if (value->IsJSObject()) { | 8566 if (value->IsJSObject()) { |
| 8608 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 8567 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 8609 HInstruction* result = | 8568 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); | 8569 Add<HStoreKeyed>(object_elements, key_constant, result, kind); |
| 8613 } else { | 8570 } else { |
| 8614 HInstruction* value_instruction = | 8571 HInstruction* value_instruction = |
| 8615 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 8572 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
| 8616 static_cast<HValue*>(NULL), kind, | 8573 static_cast<HValue*>(NULL), kind, |
| 8617 ALLOW_RETURN_HOLE); | 8574 ALLOW_RETURN_HOLE); |
| 8618 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 8575 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
| 8619 } | 8576 } |
| 8620 } | 8577 } |
| 8621 } | 8578 } |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9873 if (ShouldProduceTraceOutput()) { | 9830 if (ShouldProduceTraceOutput()) { |
| 9874 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9831 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 9875 } | 9832 } |
| 9876 | 9833 |
| 9877 #ifdef DEBUG | 9834 #ifdef DEBUG |
| 9878 graph_->Verify(false); // No full verify. | 9835 graph_->Verify(false); // No full verify. |
| 9879 #endif | 9836 #endif |
| 9880 } | 9837 } |
| 9881 | 9838 |
| 9882 } } // namespace v8::internal | 9839 } } // namespace v8::internal |
| OLD | NEW |