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

Side by Side Diff: src/hydrogen.cc

Issue 21499002: Get rid of HStringLength. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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') | src/hydrogen-instructions.h » ('j') | 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 5285 matching lines...) Expand 10 before | Expand all | Expand 10 after
5296 HValue* value = environment()->Pop(); 5296 HValue* value = environment()->Pop();
5297 HThrow* instr = Add<HThrow>(value); 5297 HThrow* instr = Add<HThrow>(value);
5298 instr->set_position(expr->position()); 5298 instr->set_position(expr->position());
5299 Add<HSimulate>(expr->id()); 5299 Add<HSimulate>(expr->id());
5300 current_block()->FinishExit(new(zone()) HAbnormalExit); 5300 current_block()->FinishExit(new(zone()) HAbnormalExit);
5301 set_current_block(NULL); 5301 set_current_block(NULL);
5302 } 5302 }
5303 5303
5304 5304
5305 HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object, 5305 HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object,
5306 HObjectAccess access) { 5306 HObjectAccess access,
5307 HValue* typecheck) {
5307 if (FLAG_track_double_fields && access.representation().IsDouble()) { 5308 if (FLAG_track_double_fields && access.representation().IsDouble()) {
5308 // load the heap number 5309 // load the heap number
5309 HLoadNamedField* heap_number = Add<HLoadNamedField>( 5310 HLoadNamedField* heap_number = Add<HLoadNamedField>(
5310 object, access.WithRepresentation(Representation::Tagged())); 5311 object, access.WithRepresentation(Representation::Tagged()));
5311 heap_number->set_type(HType::HeapNumber()); 5312 heap_number->set_type(HType::HeapNumber());
5312 // load the double value from it 5313 // load the double value from it
5313 return New<HLoadNamedField>(heap_number, 5314 return New<HLoadNamedField>(heap_number,
5314 HObjectAccess::ForHeapNumberValue()); 5315 HObjectAccess::ForHeapNumberValue(),
5316 typecheck);
5315 } 5317 }
5316 return New<HLoadNamedField>(object, access); 5318 return New<HLoadNamedField>(object, access, typecheck);
5317 } 5319 }
5318 5320
5319 5321
5322 HInstruction* HGraphBuilder::BuildLoadStringLength(HValue* object,
5323 HValue* typecheck) {
5324 if (FLAG_fold_constants && object->IsConstant()) {
5325 HConstant* constant = HConstant::cast(object);
5326 if (constant->HasStringValue()) {
5327 return New<HConstant>(constant->StringValue()->length());
5328 }
5329 }
5330 return BuildLoadNamedField(
5331 object, HObjectAccess::ForStringLength(), typecheck);
5332 }
5333
5334
5320 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric( 5335 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric(
5321 HValue* object, 5336 HValue* object,
5322 Handle<String> name, 5337 Handle<String> name,
5323 Property* expr) { 5338 Property* expr) {
5324 if (expr->IsUninitialized()) { 5339 if (expr->IsUninitialized()) {
5325 Add<HDeoptimize>(Deoptimizer::SOFT); 5340 Add<HDeoptimize>(Deoptimizer::SOFT);
5326 } 5341 }
5327 HValue* context = environment()->context(); 5342 HValue* context = environment()->context();
5328 return new(zone()) HLoadNamedGeneric(context, object, name); 5343 return new(zone()) HLoadNamedGeneric(context, object, name);
5329 } 5344 }
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
5790 ASSERT(current_block()->HasPredecessor()); 5805 ASSERT(current_block()->HasPredecessor());
5791 5806
5792 if (TryArgumentsAccess(expr)) return; 5807 if (TryArgumentsAccess(expr)) return;
5793 5808
5794 CHECK_ALIVE(VisitForValue(expr->obj())); 5809 CHECK_ALIVE(VisitForValue(expr->obj()));
5795 5810
5796 HInstruction* instr = NULL; 5811 HInstruction* instr = NULL;
5797 if (expr->IsStringLength()) { 5812 if (expr->IsStringLength()) {
5798 HValue* string = Pop(); 5813 HValue* string = Pop();
5799 BuildCheckHeapObject(string); 5814 BuildCheckHeapObject(string);
5800 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); 5815 HInstruction* checkstring =
5801 instr = NewUncasted<HStringLength>(string); 5816 AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
5817 instr = BuildLoadStringLength(string, checkstring);
5802 } else if (expr->IsStringAccess()) { 5818 } else if (expr->IsStringAccess()) {
5803 CHECK_ALIVE(VisitForValue(expr->key())); 5819 CHECK_ALIVE(VisitForValue(expr->key()));
5804 HValue* index = Pop(); 5820 HValue* index = Pop();
5805 HValue* string = Pop(); 5821 HValue* string = Pop();
5806 HValue* context = environment()->context(); 5822 HValue* context = environment()->context();
5807 HInstruction* char_code = 5823 HInstruction* char_code =
5808 BuildStringCharCodeAt(string, index); 5824 BuildStringCharCodeAt(string, index);
5809 AddInstruction(char_code); 5825 AddInstruction(char_code);
5810 instr = HStringCharFromCode::New(zone(), context, char_code); 5826 instr = HStringCharFromCode::New(zone(), context, char_code);
5811 5827
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
7566 if (c_string->HasStringValue() && c_index->HasNumberValue()) { 7582 if (c_string->HasStringValue() && c_index->HasNumberValue()) {
7567 int32_t i = c_index->NumberValueAsInteger32(); 7583 int32_t i = c_index->NumberValueAsInteger32();
7568 Handle<String> s = c_string->StringValue(); 7584 Handle<String> s = c_string->StringValue();
7569 if (i < 0 || i >= s->length()) { 7585 if (i < 0 || i >= s->length()) {
7570 return New<HConstant>(OS::nan_value()); 7586 return New<HConstant>(OS::nan_value());
7571 } 7587 }
7572 return New<HConstant>(s->Get(i)); 7588 return New<HConstant>(s->Get(i));
7573 } 7589 }
7574 } 7590 }
7575 BuildCheckHeapObject(string); 7591 BuildCheckHeapObject(string);
7576 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); 7592 HValue* checkstring =
7577 HInstruction* length = Add<HStringLength>(string); 7593 AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
7594 HInstruction* length = BuildLoadStringLength(string, checkstring);
7595 AddInstruction(length);
7578 HInstruction* checked_index = Add<HBoundsCheck>(index, length); 7596 HInstruction* checked_index = Add<HBoundsCheck>(index, length);
7579 return New<HStringCharCodeAt>(string, checked_index); 7597 return New<HStringCharCodeAt>(string, checked_index);
7580 } 7598 }
7581 7599
7582 7600
7583 // Checks if the given shift amounts have form: (sa) and (32 - sa). 7601 // Checks if the given shift amounts have form: (sa) and (32 - sa).
7584 static bool ShiftAmountsAllowReplaceByRotate(HValue* sa, 7602 static bool ShiftAmountsAllowReplaceByRotate(HValue* sa,
7585 HValue* const32_minus_sa) { 7603 HValue* const32_minus_sa) {
7586 if (!const32_minus_sa->IsSub()) return false; 7604 if (!const32_minus_sa->IsSub()) return false;
7587 HSub* sub = HSub::cast(const32_minus_sa); 7605 HSub* sub = HSub::cast(const32_minus_sa);
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
9765 if (ShouldProduceTraceOutput()) { 9783 if (ShouldProduceTraceOutput()) {
9766 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9784 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9767 } 9785 }
9768 9786
9769 #ifdef DEBUG 9787 #ifdef DEBUG
9770 graph_->Verify(false); // No full verify. 9788 graph_->Verify(false); // No full verify.
9771 #endif 9789 #endif
9772 } 9790 }
9773 9791
9774 } } // namespace v8::internal 9792 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698