Commit 5eafd7a3 authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Initial support for the %_DateField intrinsic.

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}
parent 5f609b3c
...@@ -44,6 +44,13 @@ FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() { ...@@ -44,6 +44,13 @@ FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
} }
// static
FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) {
return {kTaggedBase, JSDate::kValueOffset + index * kPointerSize,
MaybeHandle<Name>(), Type::Number(), kMachAnyTagged};
}
// static // static
FieldAccess AccessBuilder::ForFixedArrayLength() { FieldAccess AccessBuilder::ForFixedArrayLength() {
// TODO(turbofan): 2^30 is a valid upper limit for the FixedArray::length // TODO(turbofan): 2^30 is a valid upper limit for the FixedArray::length
......
...@@ -31,6 +31,9 @@ class AccessBuilder final : public AllStatic { ...@@ -31,6 +31,9 @@ class AccessBuilder final : public AllStatic {
// Provides access to JSArrayBuffer::backing_store() field. // Provides access to JSArrayBuffer::backing_store() field.
static FieldAccess ForJSArrayBufferBackingStore(); static FieldAccess ForJSArrayBufferBackingStore();
// Provides access to JSDate fields.
static FieldAccess ForJSDateField(JSDate::FieldIndex index);
// Provides access to FixedArray::length() field. // Provides access to FixedArray::length() field.
static FieldAccess ForFixedArrayLength(); static FieldAccess ForFixedArrayLength();
......
...@@ -32,6 +32,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) { ...@@ -32,6 +32,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
switch (f->function_id) { switch (f->function_id) {
case Runtime::kInlineConstructDouble: case Runtime::kInlineConstructDouble:
return ReduceConstructDouble(node); return ReduceConstructDouble(node);
case Runtime::kInlineDateField:
return ReduceDateField(node);
case Runtime::kInlineDeoptimizeNow: case Runtime::kInlineDeoptimizeNow:
return ReduceDeoptimizeNow(node); return ReduceDeoptimizeNow(node);
case Runtime::kInlineDoubleHi: case Runtime::kInlineDoubleHi:
...@@ -106,6 +108,24 @@ Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { ...@@ -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) { Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
if (mode() != kDeoptimizationEnabled) return NoChange(); if (mode() != kDeoptimizationEnabled) return NoChange();
Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
......
...@@ -32,6 +32,7 @@ class JSIntrinsicLowering final : public AdvancedReducer { ...@@ -32,6 +32,7 @@ class JSIntrinsicLowering final : public AdvancedReducer {
private: private:
Reduction ReduceConstructDouble(Node* node); Reduction ReduceConstructDouble(Node* node);
Reduction ReduceDateField(Node* node);
Reduction ReduceDeoptimizeNow(Node* node); Reduction ReduceDeoptimizeNow(Node* node);
Reduction ReduceDoubleHi(Node* node); Reduction ReduceDoubleHi(Node* node);
Reduction ReduceDoubleLo(Node* node); Reduction ReduceDoubleLo(Node* node);
......
...@@ -111,6 +111,7 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) { ...@@ -111,6 +111,7 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
// are blacklisted here and can be called without a FrameState. // are blacklisted here and can be called without a FrameState.
switch (function) { switch (function) {
case Runtime::kAllocateInTargetSpace: case Runtime::kAllocateInTargetSpace:
case Runtime::kDateField:
case Runtime::kDefineClassMethod: // TODO(jarin): Is it safe? case Runtime::kDefineClassMethod: // TODO(jarin): Is it safe?
case Runtime::kDefineGetterPropertyUnchecked: // TODO(jarin): Is it safe? case Runtime::kDefineGetterPropertyUnchecked: // TODO(jarin): Is it safe?
case Runtime::kDefineSetterPropertyUnchecked: // TODO(jarin): Is it safe? case Runtime::kDefineSetterPropertyUnchecked: // TODO(jarin): Is it safe?
...@@ -132,7 +133,6 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) { ...@@ -132,7 +133,6 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
return false; return false;
case Runtime::kInlineArguments: case Runtime::kInlineArguments:
case Runtime::kInlineCallFunction: case Runtime::kInlineCallFunction:
case Runtime::kInlineDateField: // TODO(bmeurer): Remove this.
case Runtime::kInlineDeoptimizeNow: case Runtime::kInlineDeoptimizeNow:
case Runtime::kInlineGetCallerJSFunction: case Runtime::kInlineGetCallerJSFunction:
case Runtime::kInlineGetPrototype: case Runtime::kInlineGetPrototype:
......
...@@ -1594,6 +1594,7 @@ Bounds Typer::Visitor::TypeJSCallRuntime(Node* node) { ...@@ -1594,6 +1594,7 @@ Bounds Typer::Visitor::TypeJSCallRuntime(Node* node) {
case Runtime::kInlineDoubleHi: case Runtime::kInlineDoubleHi:
return Bounds(Type::None(zone()), Type::Signed32()); return Bounds(Type::None(zone()), Type::Signed32());
case Runtime::kInlineConstructDouble: case Runtime::kInlineConstructDouble:
case Runtime::kInlineDateField:
case Runtime::kInlineMathFloor: case Runtime::kInlineMathFloor:
case Runtime::kInlineMathSqrt: case Runtime::kInlineMathSqrt:
case Runtime::kInlineMathAcos: case Runtime::kInlineMathAcos:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment