| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 8283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8294 Drop(2); // Receiver and function. | 8294 Drop(2); // Receiver and function. |
| 8295 HInstruction* result = HMul::NewImul(zone(), context(), left, right); | 8295 HInstruction* result = HMul::NewImul(zone(), context(), left, right); |
| 8296 ast_context()->ReturnInstruction(result, expr->id()); | 8296 ast_context()->ReturnInstruction(result, expr->id()); |
| 8297 return true; | 8297 return true; |
| 8298 } | 8298 } |
| 8299 break; | 8299 break; |
| 8300 case kArrayPop: { | 8300 case kArrayPop: { |
| 8301 if (receiver_map.is_null()) return false; | 8301 if (receiver_map.is_null()) return false; |
| 8302 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 8302 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
| 8303 ElementsKind elements_kind = receiver_map->elements_kind(); | 8303 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 8304 if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false; |
| 8304 if (!IsFastElementsKind(elements_kind)) return false; | 8305 if (!IsFastElementsKind(elements_kind)) return false; |
| 8305 if (receiver_map->is_observed()) return false; | 8306 if (receiver_map->is_observed()) return false; |
| 8306 if (!receiver_map->is_extensible()) return false; | 8307 if (!receiver_map->is_extensible()) return false; |
| 8307 | 8308 |
| 8308 Drop(args_count_no_receiver); | 8309 Drop(args_count_no_receiver); |
| 8309 HValue* result; | 8310 HValue* result; |
| 8310 HValue* reduced_length; | 8311 HValue* reduced_length; |
| 8311 HValue* receiver = Pop(); | 8312 HValue* receiver = Pop(); |
| 8312 | 8313 |
| 8313 HValue* checked_object = AddCheckMap(receiver, receiver_map); | 8314 HValue* checked_object = AddCheckMap(receiver, receiver_map); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8411 if (!ast_context()->IsEffect()) Drop(1); | 8412 if (!ast_context()->IsEffect()) Drop(1); |
| 8412 } | 8413 } |
| 8413 | 8414 |
| 8414 ast_context()->ReturnValue(new_size); | 8415 ast_context()->ReturnValue(new_size); |
| 8415 return true; | 8416 return true; |
| 8416 } | 8417 } |
| 8417 case kArrayShift: { | 8418 case kArrayShift: { |
| 8418 if (receiver_map.is_null()) return false; | 8419 if (receiver_map.is_null()) return false; |
| 8419 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 8420 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
| 8420 ElementsKind kind = receiver_map->elements_kind(); | 8421 ElementsKind kind = receiver_map->elements_kind(); |
| 8422 if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false; |
| 8421 if (!IsFastElementsKind(kind)) return false; | 8423 if (!IsFastElementsKind(kind)) return false; |
| 8422 if (receiver_map->is_observed()) return false; | 8424 if (receiver_map->is_observed()) return false; |
| 8423 if (!receiver_map->is_extensible()) return false; | 8425 if (!receiver_map->is_extensible()) return false; |
| 8424 | 8426 |
| 8425 // If there may be elements accessors in the prototype chain, the fast | 8427 // If there may be elements accessors in the prototype chain, the fast |
| 8426 // inlined version can't be used. | 8428 // inlined version can't be used. |
| 8427 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; | 8429 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; |
| 8428 | 8430 |
| 8429 // If there currently can be no elements accessors on the prototype chain, | 8431 // If there currently can be no elements accessors on the prototype chain, |
| 8430 // it doesn't mean that there won't be any later. Install a full prototype | 8432 // it doesn't mean that there won't be any later. Install a full prototype |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8483 length, graph()->GetConstant1()); | 8485 length, graph()->GetConstant1()); |
| 8484 new_length->ClearFlag(HValue::kCanOverflow); | 8486 new_length->ClearFlag(HValue::kCanOverflow); |
| 8485 | 8487 |
| 8486 // Copy the remaining elements. | 8488 // Copy the remaining elements. |
| 8487 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); | 8489 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); |
| 8488 { | 8490 { |
| 8489 HValue* new_key = loop.BeginBody( | 8491 HValue* new_key = loop.BeginBody( |
| 8490 graph()->GetConstant0(), new_length, Token::LT); | 8492 graph()->GetConstant0(), new_length, Token::LT); |
| 8491 HValue* key = AddUncasted<HAdd>(new_key, graph()->GetConstant1()); | 8493 HValue* key = AddUncasted<HAdd>(new_key, graph()->GetConstant1()); |
| 8492 key->ClearFlag(HValue::kCanOverflow); | 8494 key->ClearFlag(HValue::kCanOverflow); |
| 8495 ElementsKind copy_kind = |
| 8496 kind == FAST_HOLEY_SMI_ELEMENTS ? FAST_HOLEY_ELEMENTS : kind; |
| 8493 HValue* element = AddUncasted<HLoadKeyed>( | 8497 HValue* element = AddUncasted<HLoadKeyed>( |
| 8494 elements, key, lengthiszero, kind, ALLOW_RETURN_HOLE); | 8498 elements, key, lengthiszero, copy_kind, ALLOW_RETURN_HOLE); |
| 8495 HStoreKeyed* store = Add<HStoreKeyed>( | 8499 HStoreKeyed* store = |
| 8496 elements, new_key, element, kind); | 8500 Add<HStoreKeyed>(elements, new_key, element, copy_kind); |
| 8497 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 8501 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
| 8498 } | 8502 } |
| 8499 loop.EndBody(); | 8503 loop.EndBody(); |
| 8500 | 8504 |
| 8501 // Put a hole at the end. | 8505 // Put a hole at the end. |
| 8502 HValue* hole = IsFastSmiOrObjectElementsKind(kind) | 8506 HValue* hole = IsFastSmiOrObjectElementsKind(kind) |
| 8503 ? Add<HConstant>(isolate()->factory()->the_hole_value()) | 8507 ? Add<HConstant>(isolate()->factory()->the_hole_value()) |
| 8504 : Add<HConstant>(FixedDoubleArray::hole_nan_as_double()); | 8508 : Add<HConstant>(FixedDoubleArray::hole_nan_as_double()); |
| 8505 if (IsFastSmiOrObjectElementsKind(kind)) kind = FAST_HOLEY_ELEMENTS; | 8509 if (IsFastSmiOrObjectElementsKind(kind)) kind = FAST_HOLEY_ELEMENTS; |
| 8506 Add<HStoreKeyed>( | 8510 Add<HStoreKeyed>( |
| (...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11307 Handle<Object> value(fast_elements->get(i), isolate()); | 11311 Handle<Object> value(fast_elements->get(i), isolate()); |
| 11308 HValue* key_constant = Add<HConstant>(i); | 11312 HValue* key_constant = Add<HConstant>(i); |
| 11309 if (value->IsJSObject()) { | 11313 if (value->IsJSObject()) { |
| 11310 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 11314 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 11311 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 11315 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
| 11312 HInstruction* result = | 11316 HInstruction* result = |
| 11313 BuildFastLiteral(value_object, site_context); | 11317 BuildFastLiteral(value_object, site_context); |
| 11314 site_context->ExitScope(current_site, value_object); | 11318 site_context->ExitScope(current_site, value_object); |
| 11315 Add<HStoreKeyed>(object_elements, key_constant, result, kind); | 11319 Add<HStoreKeyed>(object_elements, key_constant, result, kind); |
| 11316 } else { | 11320 } else { |
| 11317 HInstruction* value_instruction = | 11321 ElementsKind copy_kind = |
| 11318 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 11322 kind == FAST_HOLEY_SMI_ELEMENTS ? FAST_HOLEY_ELEMENTS : kind; |
| 11319 static_cast<HValue*>(NULL), kind, | 11323 HInstruction* value_instruction = Add<HLoadKeyed>( |
| 11320 ALLOW_RETURN_HOLE); | 11324 boilerplate_elements, key_constant, static_cast<HValue*>(NULL), |
| 11321 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 11325 copy_kind, ALLOW_RETURN_HOLE); |
| 11326 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, |
| 11327 copy_kind); |
| 11322 } | 11328 } |
| 11323 } | 11329 } |
| 11324 } | 11330 } |
| 11325 | 11331 |
| 11326 | 11332 |
| 11327 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 11333 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
| 11328 DCHECK(!HasStackOverflow()); | 11334 DCHECK(!HasStackOverflow()); |
| 11329 DCHECK(current_block() != NULL); | 11335 DCHECK(current_block() != NULL); |
| 11330 DCHECK(current_block()->HasPredecessor()); | 11336 DCHECK(current_block()->HasPredecessor()); |
| 11331 HInstruction* instr = BuildThisFunction(); | 11337 HInstruction* instr = BuildThisFunction(); |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12672 if (ShouldProduceTraceOutput()) { | 12678 if (ShouldProduceTraceOutput()) { |
| 12673 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12679 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12674 } | 12680 } |
| 12675 | 12681 |
| 12676 #ifdef DEBUG | 12682 #ifdef DEBUG |
| 12677 graph_->Verify(false); // No full verify. | 12683 graph_->Verify(false); // No full verify. |
| 12678 #endif | 12684 #endif |
| 12679 } | 12685 } |
| 12680 | 12686 |
| 12681 } } // namespace v8::internal | 12687 } } // namespace v8::internal |
| OLD | NEW |