[turbofan] Initial support for the %_DateField intrinsic.
authorBenedikt Meurer <bmeurer@chromium.org>
Mon, 8 Jun 2015 11:47:03 +0000 (13:47 +0200)
committerBenedikt Meurer <bmeurer@chromium.org>
Mon, 8 Jun 2015 11:47:28 +0000 (11:47 +0000)
This only introduces better typing and lowering for access to the value
field.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1169723002

Cr-Commit-Position: refs/heads/master@{#28836}

src/compiler/access-builder.cc
src/compiler/access-builder.h
src/compiler/js-intrinsic-lowering.cc
src/compiler/js-intrinsic-lowering.h
src/compiler/linkage.cc
src/compiler/typer.cc

index c03b787..a28075c 100644 (file)
@@ -45,6 +45,13 @@ FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
 
 
 // static
+FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) {
+  return {kTaggedBase, JSDate::kValueOffset + index * kPointerSize,
+          MaybeHandle<Name>(), Type::Number(), kMachAnyTagged};
+}
+
+
+// static
 FieldAccess AccessBuilder::ForFixedArrayLength() {
   // TODO(turbofan): 2^30 is a valid upper limit for the FixedArray::length
   // field, although it's not the best. If we had a Zone we could create an
index 7c6029d..e4d1332 100644 (file)
@@ -31,6 +31,9 @@ class AccessBuilder final : public AllStatic {
   // Provides access to JSArrayBuffer::backing_store() field.
   static FieldAccess ForJSArrayBufferBackingStore();
 
+  // Provides access to JSDate fields.
+  static FieldAccess ForJSDateField(JSDate::FieldIndex index);
+
   // Provides access to FixedArray::length() field.
   static FieldAccess ForFixedArrayLength();
 
index b679a75..891e17f 100644 (file)
@@ -32,6 +32,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
   switch (f->function_id) {
     case Runtime::kInlineConstructDouble:
       return ReduceConstructDouble(node);
+    case Runtime::kInlineDateField:
+      return ReduceDateField(node);
     case Runtime::kInlineDeoptimizeNow:
       return ReduceDeoptimizeNow(node);
     case Runtime::kInlineDoubleHi:
@@ -106,6 +108,24 @@ Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) {
 }
 
 
+Reduction JSIntrinsicLowering::ReduceDateField(Node* node) {
+  Node* const value = NodeProperties::GetValueInput(node, 0);
+  Node* const index = NodeProperties::GetValueInput(node, 1);
+  Node* const effect = NodeProperties::GetEffectInput(node);
+  Node* const control = NodeProperties::GetControlInput(node);
+  NumberMatcher mindex(index);
+  if (mindex.Is(JSDate::kDateValue)) {
+    return Change(
+        node,
+        simplified()->LoadField(AccessBuilder::ForJSDateField(
+            static_cast<JSDate::FieldIndex>(static_cast<int>(mindex.Value())))),
+        value, effect, control);
+  }
+  // TODO(turbofan): Optimize more patterns.
+  return NoChange();
+}
+
+
 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
   if (mode() != kDeoptimizationEnabled) return NoChange();
   Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
index 3ceabd6..be6e536 100644 (file)
@@ -32,6 +32,7 @@ class JSIntrinsicLowering final : public AdvancedReducer {
 
  private:
   Reduction ReduceConstructDouble(Node* node);
+  Reduction ReduceDateField(Node* node);
   Reduction ReduceDeoptimizeNow(Node* node);
   Reduction ReduceDoubleHi(Node* node);
   Reduction ReduceDoubleLo(Node* node);
index afc999b..d61ff20 100644 (file)
@@ -111,6 +111,7 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
   // are blacklisted here and can be called without a FrameState.
   switch (function) {
     case Runtime::kAllocateInTargetSpace:
+    case Runtime::kDateField:
     case Runtime::kDefineClassMethod:              // TODO(jarin): Is it safe?
     case Runtime::kDefineGetterPropertyUnchecked:  // TODO(jarin): Is it safe?
     case Runtime::kDefineSetterPropertyUnchecked:  // TODO(jarin): Is it safe?
@@ -132,7 +133,6 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
       return false;
     case Runtime::kInlineArguments:
     case Runtime::kInlineCallFunction:
-    case Runtime::kInlineDateField:  // TODO(bmeurer): Remove this.
     case Runtime::kInlineDeoptimizeNow:
     case Runtime::kInlineGetCallerJSFunction:
     case Runtime::kInlineGetPrototype:
index 9cc7cfc..0f6c4d1 100644 (file)
@@ -1594,6 +1594,7 @@ Bounds Typer::Visitor::TypeJSCallRuntime(Node* node) {
     case Runtime::kInlineDoubleHi:
       return Bounds(Type::None(zone()), Type::Signed32());
     case Runtime::kInlineConstructDouble:
+    case Runtime::kInlineDateField:
     case Runtime::kInlineMathFloor:
     case Runtime::kInlineMathSqrt:
     case Runtime::kInlineMathAcos: