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

Side by Side Diff: src/hydrogen.cc

Issue 82943005: Safe HGraphBuilder::Add<> and New<> (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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
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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 set_current_block(NULL); 1188 set_current_block(NULL);
1189 } 1189 }
1190 } 1190 }
1191 1191
1192 1192
1193 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) { 1193 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) {
1194 if (FLAG_native_code_counters && counter->Enabled()) { 1194 if (FLAG_native_code_counters && counter->Enabled()) {
1195 HValue* reference = Add<HConstant>(ExternalReference(counter)); 1195 HValue* reference = Add<HConstant>(ExternalReference(counter));
1196 HValue* old_value = Add<HLoadNamedField>(reference, 1196 HValue* old_value = Add<HLoadNamedField>(reference,
1197 HObjectAccess::ForCounter()); 1197 HObjectAccess::ForCounter());
1198 HValue* new_value = Add<HAdd>(old_value, graph()->GetConstant1()); 1198 HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1());
1199 new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow 1199 new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow
1200 Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(), 1200 Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(),
1201 new_value); 1201 new_value);
1202 } 1202 }
1203 } 1203 }
1204 1204
1205 1205
1206 void HGraphBuilder::AddSimulate(BailoutId id, 1206 void HGraphBuilder::AddSimulate(BailoutId id,
1207 RemovableSimulate removable) { 1207 RemovableSimulate removable) {
1208 ASSERT(current_block() != NULL); 1208 ASSERT(current_block() != NULL);
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 HValue* elements = AddLoadElements(receiver); 1532 HValue* elements = AddLoadElements(receiver);
1533 1533
1534 HValue* hash = BuildElementIndexHash(key); 1534 HValue* hash = BuildElementIndexHash(key);
1535 1535
1536 HValue* capacity = Add<HLoadKeyed>( 1536 HValue* capacity = Add<HLoadKeyed>(
1537 elements, 1537 elements,
1538 Add<HConstant>(NameDictionary::kCapacityIndex), 1538 Add<HConstant>(NameDictionary::kCapacityIndex),
1539 static_cast<HValue*>(NULL), 1539 static_cast<HValue*>(NULL),
1540 FAST_SMI_ELEMENTS); 1540 FAST_SMI_ELEMENTS);
1541 1541
1542 HValue* mask = Add<HSub>(capacity, graph()->GetConstant1()); 1542 HValue* mask = AddUncasted<HSub>(capacity, graph()->GetConstant1());
1543 mask->ChangeRepresentation(Representation::Integer32()); 1543 mask->ChangeRepresentation(Representation::Integer32());
1544 mask->ClearFlag(HValue::kCanOverflow); 1544 mask->ClearFlag(HValue::kCanOverflow);
1545 1545
1546 return BuildUncheckedDictionaryElementLoadHelper(elements, key, 1546 return BuildUncheckedDictionaryElementLoadHelper(elements, key,
1547 hash, mask, 0); 1547 hash, mask, 0);
1548 } 1548 }
1549 1549
1550 1550
1551 HValue* HGraphBuilder::BuildNumberToString(HValue* object, 1551 HValue* HGraphBuilder::BuildNumberToString(HValue* object,
1552 Handle<Type> type) { 1552 Handle<Type> type) {
(...skipping 11 matching lines...) Expand all
1564 graph()->CreateBasicBlock()); 1564 graph()->CreateBasicBlock());
1565 1565
1566 // Load the number string cache. 1566 // Load the number string cache.
1567 HValue* number_string_cache = 1567 HValue* number_string_cache =
1568 Add<HLoadRoot>(Heap::kNumberStringCacheRootIndex); 1568 Add<HLoadRoot>(Heap::kNumberStringCacheRootIndex);
1569 1569
1570 // Make the hash mask from the length of the number string cache. It 1570 // Make the hash mask from the length of the number string cache. It
1571 // contains two elements (number and string) for each cache entry. 1571 // contains two elements (number and string) for each cache entry.
1572 HValue* mask = AddLoadFixedArrayLength(number_string_cache); 1572 HValue* mask = AddLoadFixedArrayLength(number_string_cache);
1573 mask->set_type(HType::Smi()); 1573 mask->set_type(HType::Smi());
1574 mask = Add<HSar>(mask, graph()->GetConstant1()); 1574 mask = AddUncasted<HSar>(mask, graph()->GetConstant1());
1575 mask = Add<HSub>(mask, graph()->GetConstant1()); 1575 mask = AddUncasted<HSub>(mask, graph()->GetConstant1());
1576 1576
1577 // Check whether object is a smi. 1577 // Check whether object is a smi.
1578 IfBuilder if_objectissmi(this); 1578 IfBuilder if_objectissmi(this);
1579 if_objectissmi.If<HIsSmiAndBranch>(object); 1579 if_objectissmi.If<HIsSmiAndBranch>(object);
1580 if_objectissmi.Then(); 1580 if_objectissmi.Then();
1581 { 1581 {
1582 // Compute hash for smi similar to smi_get_hash(). 1582 // Compute hash for smi similar to smi_get_hash().
1583 HValue* hash = AddUncasted<HBitwise>(Token::BIT_AND, object, mask); 1583 HValue* hash = AddUncasted<HBitwise>(Token::BIT_AND, object, mask);
1584 1584
1585 // Load the key. 1585 // Load the key.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 HValue* dst, 1709 HValue* dst,
1710 HValue* dst_offset, 1710 HValue* dst_offset,
1711 String::Encoding dst_encoding, 1711 String::Encoding dst_encoding,
1712 HValue* length) { 1712 HValue* length) {
1713 ASSERT(dst_encoding != String::ONE_BYTE_ENCODING || 1713 ASSERT(dst_encoding != String::ONE_BYTE_ENCODING ||
1714 src_encoding == String::ONE_BYTE_ENCODING); 1714 src_encoding == String::ONE_BYTE_ENCODING);
1715 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); 1715 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement);
1716 HValue* index = loop.BeginBody(graph()->GetConstant0(), length, Token::LT); 1716 HValue* index = loop.BeginBody(graph()->GetConstant0(), length, Token::LT);
1717 { 1717 {
1718 HValue* src_index = AddUncasted<HAdd>(src_offset, index); 1718 HValue* src_index = AddUncasted<HAdd>(src_offset, index);
1719 HValue* value = Add<HSeqStringGetChar>(src_encoding, src, src_index); 1719 HValue* value =
1720 AddUncasted<HSeqStringGetChar>(src_encoding, src, src_index);
1720 HValue* dst_index = AddUncasted<HAdd>(dst_offset, index); 1721 HValue* dst_index = AddUncasted<HAdd>(dst_offset, index);
1721 Add<HSeqStringSetChar>(dst_encoding, dst, dst_index, value); 1722 Add<HSeqStringSetChar>(dst_encoding, dst, dst_index, value);
1722 } 1723 }
1723 loop.EndBody(); 1724 loop.EndBody();
1724 } 1725 }
1725 1726
1726 1727
1727 HValue* HGraphBuilder::BuildUncheckedStringAdd(HValue* left, 1728 HValue* HGraphBuilder::BuildUncheckedStringAdd(HValue* left,
1728 HValue* right, 1729 HValue* right,
1729 PretenureFlag pretenure_flag) { 1730 PretenureFlag pretenure_flag) {
(...skipping 8116 matching lines...) Expand 10 before | Expand all | Expand 10 after
9846 } 9847 }
9847 9848
9848 9849
9849 // Fast support for StringAdd. 9850 // Fast support for StringAdd.
9850 void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) { 9851 void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) {
9851 ASSERT_EQ(2, call->arguments()->length()); 9852 ASSERT_EQ(2, call->arguments()->length());
9852 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9853 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9853 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9854 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9854 HValue* right = Pop(); 9855 HValue* right = Pop();
9855 HValue* left = Pop(); 9856 HValue* left = Pop();
9856 HInstruction* result = New<HStringAdd>(left, right, STRING_ADD_CHECK_BOTH); 9857 HInstruction* result =
9858 NewUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_BOTH);
9857 return ast_context()->ReturnInstruction(result, call->id()); 9859 return ast_context()->ReturnInstruction(result, call->id());
9858 } 9860 }
9859 9861
9860 9862
9861 // Fast support for SubString. 9863 // Fast support for SubString.
9862 void HOptimizedGraphBuilder::GenerateSubString(CallRuntime* call) { 9864 void HOptimizedGraphBuilder::GenerateSubString(CallRuntime* call) {
9863 ASSERT_EQ(3, call->arguments()->length()); 9865 ASSERT_EQ(3, call->arguments()->length());
9864 CHECK_ALIVE(VisitArgumentList(call->arguments())); 9866 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9865 HCallStub* result = New<HCallStub>(CodeStub::SubString, 3); 9867 HCallStub* result = New<HCallStub>(CodeStub::SubString, 3);
9866 Drop(3); 9868 Drop(3);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
9975 result->set_transcendental_type(TranscendentalCache::LOG); 9977 result->set_transcendental_type(TranscendentalCache::LOG);
9976 Drop(1); 9978 Drop(1);
9977 return ast_context()->ReturnInstruction(result, call->id()); 9979 return ast_context()->ReturnInstruction(result, call->id());
9978 } 9980 }
9979 9981
9980 9982
9981 void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) { 9983 void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) {
9982 ASSERT(call->arguments()->length() == 1); 9984 ASSERT(call->arguments()->length() == 1);
9983 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9985 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9984 HValue* value = Pop(); 9986 HValue* value = Pop();
9985 HInstruction* result = New<HUnaryMathOperation>(value, kMathSqrt); 9987 HInstruction* result = NewUncasted<HUnaryMathOperation>(value, kMathSqrt);
9986 return ast_context()->ReturnInstruction(result, call->id()); 9988 return ast_context()->ReturnInstruction(result, call->id());
9987 } 9989 }
9988 9990
9989 9991
9990 // Check whether two RegExps are equivalent 9992 // Check whether two RegExps are equivalent
9991 void HOptimizedGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) { 9993 void HOptimizedGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) {
9992 return Bailout(kInlinedRuntimeFunctionIsRegExpEquivalent); 9994 return Bailout(kInlinedRuntimeFunctionIsRegExpEquivalent);
9993 } 9995 }
9994 9996
9995 9997
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
10635 if (ShouldProduceTraceOutput()) { 10637 if (ShouldProduceTraceOutput()) {
10636 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10638 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10637 } 10639 }
10638 10640
10639 #ifdef DEBUG 10641 #ifdef DEBUG
10640 graph_->Verify(false); // No full verify. 10642 graph_->Verify(false); // No full verify.
10641 #endif 10643 #endif
10642 } 10644 }
10643 10645
10644 } } // namespace v8::internal 10646 } } // namespace v8::internal
OLDNEW
« src/hydrogen.h ('K') | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698