Reviewers: mvstanton,

Message:
Hey Michael,
Here's the next constant optimization. PTAL
-- Benedikt

Description:
Convert constant numbers at compile time.

TEST=mjsunit/number-tostring

Please review this at https://codereview.chromium.org/77553005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+7, -0 lines):
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 22da9477e53608ce1b4df08357bfce25960e2e53..70ca761eb7516b37a2269db83beba27255dbfca7 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1541,6 +1541,13 @@ HValue* HGraphBuilder::BuildNumberToString(HValue* object,
                                            Handle<Type> type) {
   NoObservableSideEffectsScope scope(this);

+  // Convert constant numbers at compile time.
+  if (object->IsConstant()) {
+    Handle<Object> number = HConstant::cast(object)->handle(isolate());
+    Handle<String> result = isolate()->factory()->NumberToString(number);
+    return Add<HConstant>(result);
+  }
+
   // Create a joinable continuation.
   HIfContinuation found(graph()->CreateBasicBlock(),
                         graph()->CreateBasicBlock());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to