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() {
}
// 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
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
......@@ -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:
......
......@@ -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:
......
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