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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 45c5780cdecb2f129cbdf2843f7c08db4c145c87..06a1a9aba043615fbef2eb105e12b1fd4a17608f 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5303,7 +5303,8 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) {
HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object,
- HObjectAccess access) {
+ HObjectAccess access,
+ HValue* typecheck) {
if (FLAG_track_double_fields && access.representation().IsDouble()) {
// load the heap number
HLoadNamedField* heap_number = Add<HLoadNamedField>(
@@ -5311,9 +5312,23 @@ HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object,
heap_number->set_type(HType::HeapNumber());
// load the double value from it
return New<HLoadNamedField>(heap_number,
- HObjectAccess::ForHeapNumberValue());
+ HObjectAccess::ForHeapNumberValue(),
+ typecheck);
}
- return New<HLoadNamedField>(object, access);
+ return New<HLoadNamedField>(object, access, typecheck);
+}
+
+
+HInstruction* HGraphBuilder::BuildLoadStringLength(HValue* object,
+ HValue* typecheck) {
+ if (FLAG_fold_constants && object->IsConstant()) {
+ HConstant* constant = HConstant::cast(object);
+ if (constant->HasStringValue()) {
+ return New<HConstant>(constant->StringValue()->length());
+ }
+ }
+ return BuildLoadNamedField(
+ object, HObjectAccess::ForStringLength(), typecheck);
}
@@ -5797,8 +5812,9 @@ void HOptimizedGraphBuilder::VisitProperty(Property* expr) {
if (expr->IsStringLength()) {
HValue* string = Pop();
BuildCheckHeapObject(string);
- AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
- instr = NewUncasted<HStringLength>(string);
+ HInstruction* checkstring =
+ AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
+ instr = BuildLoadStringLength(string, checkstring);
} else if (expr->IsStringAccess()) {
CHECK_ALIVE(VisitForValue(expr->key()));
HValue* index = Pop();
@@ -7573,8 +7589,10 @@ HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt(
}
}
BuildCheckHeapObject(string);
- AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
- HInstruction* length = Add<HStringLength>(string);
+ HValue* checkstring =
+ AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
+ HInstruction* length = BuildLoadStringLength(string, checkstring);
+ AddInstruction(length);
HInstruction* checked_index = Add<HBoundsCheck>(index, length);
return New<HStringCharCodeAt>(string, checked_index);
}
« 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