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 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 | 1383 |
1384 | 1384 |
1385 HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, | 1385 HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, |
1386 HValue* elements, | 1386 HValue* elements, |
1387 ElementsKind kind, | 1387 ElementsKind kind, |
1388 HValue* length) { | 1388 HValue* length) { |
1389 Factory* factory = isolate()->factory(); | 1389 Factory* factory = isolate()->factory(); |
1390 | 1390 |
1391 IfBuilder cow_checker(this); | 1391 IfBuilder cow_checker(this); |
1392 | 1392 |
1393 cow_checker.If<HCompareMap>( | 1393 cow_checker.If<HCompareMap>(elements, factory->fixed_cow_array_map()); |
1394 elements, factory->fixed_cow_array_map(), top_info()); | |
1395 cow_checker.Then(); | 1394 cow_checker.Then(); |
1396 | 1395 |
1397 HValue* capacity = AddLoadFixedArrayLength(elements); | 1396 HValue* capacity = AddLoadFixedArrayLength(elements); |
1398 | 1397 |
1399 HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, | 1398 HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, |
1400 kind, length, capacity); | 1399 kind, length, capacity); |
1401 | 1400 |
1402 environment()->Push(new_elements); | 1401 environment()->Push(new_elements); |
1403 | 1402 |
1404 cow_checker.Else(); | 1403 cow_checker.Else(); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 if_objectiskey.JoinContinuation(&found); | 1700 if_objectiskey.JoinContinuation(&found); |
1702 } | 1701 } |
1703 if_objectissmi.Else(); | 1702 if_objectissmi.Else(); |
1704 { | 1703 { |
1705 if (type->Is(Type::Smi())) { | 1704 if (type->Is(Type::Smi())) { |
1706 if_objectissmi.Deopt("Expected smi"); | 1705 if_objectissmi.Deopt("Expected smi"); |
1707 } else { | 1706 } else { |
1708 // Check if the object is a heap number. | 1707 // Check if the object is a heap number. |
1709 IfBuilder if_objectisnumber(this); | 1708 IfBuilder if_objectisnumber(this); |
1710 HValue* objectisnumber = if_objectisnumber.If<HCompareMap>( | 1709 HValue* objectisnumber = if_objectisnumber.If<HCompareMap>( |
1711 object, isolate()->factory()->heap_number_map(), top_info()); | 1710 object, isolate()->factory()->heap_number_map()); |
1712 if_objectisnumber.Then(); | 1711 if_objectisnumber.Then(); |
1713 { | 1712 { |
1714 // Compute hash for heap number similar to double_get_hash(). | 1713 // Compute hash for heap number similar to double_get_hash(). |
1715 HValue* low = Add<HLoadNamedField>( | 1714 HValue* low = Add<HLoadNamedField>( |
1716 object, objectisnumber, | 1715 object, objectisnumber, |
1717 HObjectAccess::ForHeapNumberValueLowestBits()); | 1716 HObjectAccess::ForHeapNumberValueLowestBits()); |
1718 HValue* high = Add<HLoadNamedField>( | 1717 HValue* high = Add<HLoadNamedField>( |
1719 object, objectisnumber, | 1718 object, objectisnumber, |
1720 HObjectAccess::ForHeapNumberValueHighestBits()); | 1719 HObjectAccess::ForHeapNumberValueHighestBits()); |
1721 HValue* hash = AddUncasted<HBitwise>(Token::BIT_XOR, low, high); | 1720 HValue* hash = AddUncasted<HBitwise>(Token::BIT_XOR, low, high); |
(...skipping 3923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5645 } | 5644 } |
5646 } | 5645 } |
5647 ++count; | 5646 ++count; |
5648 HBasicBlock* if_true = graph()->CreateBasicBlock(); | 5647 HBasicBlock* if_true = graph()->CreateBasicBlock(); |
5649 HBasicBlock* if_false = graph()->CreateBasicBlock(); | 5648 HBasicBlock* if_false = graph()->CreateBasicBlock(); |
5650 HUnaryControlInstruction* compare; | 5649 HUnaryControlInstruction* compare; |
5651 | 5650 |
5652 HValue* dependency; | 5651 HValue* dependency; |
5653 if (info.type()->Is(Type::Number())) { | 5652 if (info.type()->Is(Type::Number())) { |
5654 Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); | 5653 Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); |
5655 compare = New<HCompareMap>(object, heap_number_map, top_info(), | 5654 compare = New<HCompareMap>(object, heap_number_map, if_true, if_false); |
5656 if_true, if_false); | |
5657 dependency = smi_check; | 5655 dependency = smi_check; |
5658 } else if (info.type()->Is(Type::String())) { | 5656 } else if (info.type()->Is(Type::String())) { |
5659 compare = New<HIsStringAndBranch>(object, if_true, if_false); | 5657 compare = New<HIsStringAndBranch>(object, if_true, if_false); |
5660 dependency = compare; | 5658 dependency = compare; |
5661 } else { | 5659 } else { |
5662 compare = New<HCompareMap>(object, info.map(), top_info(), | 5660 compare = New<HCompareMap>(object, info.map(), if_true, if_false); |
5663 if_true, if_false); | |
5664 dependency = compare; | 5661 dependency = compare; |
5665 } | 5662 } |
5666 FinishCurrentBlock(compare); | 5663 FinishCurrentBlock(compare); |
5667 | 5664 |
5668 if (info.type()->Is(Type::Number())) { | 5665 if (info.type()->Is(Type::Number())) { |
5669 Goto(if_true, number_block); | 5666 Goto(if_true, number_block); |
5670 if_true = number_block; | 5667 if_true = number_block; |
5671 number_block->SetJoinId(ast_id); | 5668 number_block->SetJoinId(ast_id); |
5672 } | 5669 } |
5673 | 5670 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6293 // Remember the most general elements kind, the code for its load will | 6290 // Remember the most general elements kind, the code for its load will |
6294 // properly handle all of the more specific cases. | 6291 // properly handle all of the more specific cases. |
6295 if ((i == 0) || IsMoreGeneralElementsKindTransition( | 6292 if ((i == 0) || IsMoreGeneralElementsKindTransition( |
6296 most_general_consolidated_map->elements_kind(), | 6293 most_general_consolidated_map->elements_kind(), |
6297 map->elements_kind())) { | 6294 map->elements_kind())) { |
6298 most_general_consolidated_map = map; | 6295 most_general_consolidated_map = map; |
6299 } | 6296 } |
6300 } | 6297 } |
6301 if (!has_double_maps && !has_smi_or_object_maps) return NULL; | 6298 if (!has_double_maps && !has_smi_or_object_maps) return NULL; |
6302 | 6299 |
6303 HCheckMaps* checked_object = Add<HCheckMaps>(object, maps, top_info()); | 6300 HCheckMaps* checked_object = Add<HCheckMaps>(object, maps); |
6304 // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. | 6301 // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. |
6305 // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. | 6302 // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. |
6306 ElementsKind consolidated_elements_kind = has_seen_holey_elements | 6303 ElementsKind consolidated_elements_kind = has_seen_holey_elements |
6307 ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) | 6304 ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) |
6308 : most_general_consolidated_map->elements_kind(); | 6305 : most_general_consolidated_map->elements_kind(); |
6309 HInstruction* instr = BuildUncheckedMonomorphicElementAccess( | 6306 HInstruction* instr = BuildUncheckedMonomorphicElementAccess( |
6310 checked_object, key, val, | 6307 checked_object, key, val, |
6311 most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, | 6308 most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, |
6312 consolidated_elements_kind, | 6309 consolidated_elements_kind, |
6313 LOAD, NEVER_RETURN_HOLE, STANDARD_STORE); | 6310 LOAD, NEVER_RETURN_HOLE, STANDARD_STORE); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6391 | 6388 |
6392 HBasicBlock* join = graph()->CreateBasicBlock(); | 6389 HBasicBlock* join = graph()->CreateBasicBlock(); |
6393 | 6390 |
6394 for (int i = 0; i < untransitionable_maps.length(); ++i) { | 6391 for (int i = 0; i < untransitionable_maps.length(); ++i) { |
6395 Handle<Map> map = untransitionable_maps[i]; | 6392 Handle<Map> map = untransitionable_maps[i]; |
6396 if (!map->IsJSObjectMap()) continue; | 6393 if (!map->IsJSObjectMap()) continue; |
6397 ElementsKind elements_kind = map->elements_kind(); | 6394 ElementsKind elements_kind = map->elements_kind(); |
6398 HBasicBlock* this_map = graph()->CreateBasicBlock(); | 6395 HBasicBlock* this_map = graph()->CreateBasicBlock(); |
6399 HBasicBlock* other_map = graph()->CreateBasicBlock(); | 6396 HBasicBlock* other_map = graph()->CreateBasicBlock(); |
6400 HCompareMap* mapcompare = | 6397 HCompareMap* mapcompare = |
6401 New<HCompareMap>(object, map, top_info(), this_map, other_map); | 6398 New<HCompareMap>(object, map, this_map, other_map); |
6402 FinishCurrentBlock(mapcompare); | 6399 FinishCurrentBlock(mapcompare); |
6403 | 6400 |
6404 set_current_block(this_map); | 6401 set_current_block(this_map); |
6405 HInstruction* access = NULL; | 6402 HInstruction* access = NULL; |
6406 if (IsDictionaryElementsKind(elements_kind)) { | 6403 if (IsDictionaryElementsKind(elements_kind)) { |
6407 access = AddInstruction(BuildKeyedGeneric(access_type, object, key, val)); | 6404 access = AddInstruction(BuildKeyedGeneric(access_type, object, key, val)); |
6408 } else { | 6405 } else { |
6409 ASSERT(IsFastElementsKind(elements_kind) || | 6406 ASSERT(IsFastElementsKind(elements_kind) || |
6410 IsExternalArrayElementsKind(elements_kind)); | 6407 IsExternalArrayElementsKind(elements_kind)); |
6411 LoadKeyedHoleMode load_mode = BuildKeyedHoleMode(map); | 6408 LoadKeyedHoleMode load_mode = BuildKeyedHoleMode(map); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6599 } | 6596 } |
6600 | 6597 |
6601 HValue* checked_object; | 6598 HValue* checked_object; |
6602 // Type::Number() is only supported by polymorphic load/call handling. | 6599 // Type::Number() is only supported by polymorphic load/call handling. |
6603 ASSERT(!info.type()->Is(Type::Number())); | 6600 ASSERT(!info.type()->Is(Type::Number())); |
6604 BuildCheckHeapObject(object); | 6601 BuildCheckHeapObject(object); |
6605 if (AreStringTypes(types)) { | 6602 if (AreStringTypes(types)) { |
6606 checked_object = | 6603 checked_object = |
6607 Add<HCheckInstanceType>(object, HCheckInstanceType::IS_STRING); | 6604 Add<HCheckInstanceType>(object, HCheckInstanceType::IS_STRING); |
6608 } else { | 6605 } else { |
6609 checked_object = Add<HCheckMaps>(object, types, top_info()); | 6606 checked_object = Add<HCheckMaps>(object, types); |
6610 } | 6607 } |
6611 return BuildMonomorphicAccess( | 6608 return BuildMonomorphicAccess( |
6612 &info, object, checked_object, value, ast_id, return_id); | 6609 &info, object, checked_object, value, ast_id, return_id); |
6613 } | 6610 } |
6614 | 6611 |
6615 return BuildNamedGeneric(access, object, name, value, is_uninitialized); | 6612 return BuildNamedGeneric(access, object, name, value, is_uninitialized); |
6616 } | 6613 } |
6617 | 6614 |
6618 | 6615 |
6619 void HOptimizedGraphBuilder::PushLoad(Property* expr, | 6616 void HOptimizedGraphBuilder::PushLoad(Property* expr, |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6851 } | 6848 } |
6852 } | 6849 } |
6853 ++count; | 6850 ++count; |
6854 HBasicBlock* if_true = graph()->CreateBasicBlock(); | 6851 HBasicBlock* if_true = graph()->CreateBasicBlock(); |
6855 HBasicBlock* if_false = graph()->CreateBasicBlock(); | 6852 HBasicBlock* if_false = graph()->CreateBasicBlock(); |
6856 HUnaryControlInstruction* compare; | 6853 HUnaryControlInstruction* compare; |
6857 | 6854 |
6858 Handle<Map> map = info.map(); | 6855 Handle<Map> map = info.map(); |
6859 if (info.type()->Is(Type::Number())) { | 6856 if (info.type()->Is(Type::Number())) { |
6860 Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); | 6857 Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); |
6861 compare = New<HCompareMap>(receiver, heap_number_map, top_info(), | 6858 compare = New<HCompareMap>(receiver, heap_number_map, if_true, if_false); |
6862 if_true, if_false); | |
6863 } else if (info.type()->Is(Type::String())) { | 6859 } else if (info.type()->Is(Type::String())) { |
6864 compare = New<HIsStringAndBranch>(receiver, if_true, if_false); | 6860 compare = New<HIsStringAndBranch>(receiver, if_true, if_false); |
6865 } else { | 6861 } else { |
6866 compare = New<HCompareMap>(receiver, map, top_info(), | 6862 compare = New<HCompareMap>(receiver, map, if_true, if_false); |
6867 if_true, if_false); | |
6868 } | 6863 } |
6869 FinishCurrentBlock(compare); | 6864 FinishCurrentBlock(compare); |
6870 | 6865 |
6871 if (info.type()->Is(Type::Number())) { | 6866 if (info.type()->Is(Type::Number())) { |
6872 Goto(if_true, number_block); | 6867 Goto(if_true, number_block); |
6873 if_true = number_block; | 6868 if_true = number_block; |
6874 number_block->SetJoinId(expr->id()); | 6869 number_block->SetJoinId(expr->id()); |
6875 } | 6870 } |
6876 | 6871 |
6877 set_current_block(if_true); | 6872 set_current_block(if_true); |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7702 PrintF("Inlining api function "); | 7697 PrintF("Inlining api function "); |
7703 function->ShortPrint(); | 7698 function->ShortPrint(); |
7704 PrintF("\n"); | 7699 PrintF("\n"); |
7705 } | 7700 } |
7706 | 7701 |
7707 bool drop_extra = false; | 7702 bool drop_extra = false; |
7708 switch (call_type) { | 7703 switch (call_type) { |
7709 case kCallApiFunction: | 7704 case kCallApiFunction: |
7710 case kCallApiMethod: | 7705 case kCallApiMethod: |
7711 // Need to check that none of the receiver maps could have changed. | 7706 // Need to check that none of the receiver maps could have changed. |
7712 Add<HCheckMaps>(receiver, receiver_maps, top_info()); | 7707 Add<HCheckMaps>(receiver, receiver_maps); |
7713 // Need to ensure the chain between receiver and api_holder is intact. | 7708 // Need to ensure the chain between receiver and api_holder is intact. |
7714 if (holder_lookup == CallOptimization::kHolderFound) { | 7709 if (holder_lookup == CallOptimization::kHolderFound) { |
7715 AddCheckPrototypeMaps(api_holder, receiver_maps->first()); | 7710 AddCheckPrototypeMaps(api_holder, receiver_maps->first()); |
7716 } else { | 7711 } else { |
7717 ASSERT_EQ(holder_lookup, CallOptimization::kHolderIsReceiver); | 7712 ASSERT_EQ(holder_lookup, CallOptimization::kHolderIsReceiver); |
7718 } | 7713 } |
7719 // Includes receiver. | 7714 // Includes receiver. |
7720 PushArgumentsFromEnvironment(argc + 1); | 7715 PushArgumentsFromEnvironment(argc + 1); |
7721 // Drop function after call. | 7716 // Drop function after call. |
7722 drop_extra = true; | 7717 drop_extra = true; |
(...skipping 3464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11187 if (ShouldProduceTraceOutput()) { | 11182 if (ShouldProduceTraceOutput()) { |
11188 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11183 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11189 } | 11184 } |
11190 | 11185 |
11191 #ifdef DEBUG | 11186 #ifdef DEBUG |
11192 graph_->Verify(false); // No full verify. | 11187 graph_->Verify(false); // No full verify. |
11193 #endif | 11188 #endif |
11194 } | 11189 } |
11195 | 11190 |
11196 } } // namespace v8::internal | 11191 } } // namespace v8::internal |
OLD | NEW |