Revision: 25107
Author: bmeu...@chromium.org
Date: Tue Nov 4 12:58:17 2014 UTC
Log: [turbofan] Add AllocateHeapNumberStub to avoid runtime call.
TEST=unittests
R=mstarzin...@chromium.org
Review URL: https://codereview.chromium.org/703473004
https://code.google.com/p/v8/source/detail?r=25107
Modified:
/branches/bleeding_edge/src/arm/interface-descriptors-arm.cc
/branches/bleeding_edge/src/arm64/interface-descriptors-arm64.cc
/branches/bleeding_edge/src/code-factory.cc
/branches/bleeding_edge/src/code-factory.h
/branches/bleeding_edge/src/code-stubs-hydrogen.cc
/branches/bleeding_edge/src/code-stubs.cc
/branches/bleeding_edge/src/code-stubs.h
/branches/bleeding_edge/src/compiler/change-lowering.cc
/branches/bleeding_edge/src/ia32/interface-descriptors-ia32.cc
/branches/bleeding_edge/src/interface-descriptors.h
/branches/bleeding_edge/src/x64/interface-descriptors-x64.cc
/branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/node-test-utils.cc
/branches/bleeding_edge/test/unittests/compiler/node-test-utils.h
=======================================
--- /branches/bleeding_edge/src/arm/interface-descriptors-arm.cc Tue Sep 30
14:54:14 2014 UTC
+++ /branches/bleeding_edge/src/arm/interface-descriptors-arm.cc Tue Nov 4
12:58:17 2014 UTC
@@ -150,6 +150,15 @@
Register registers[] = {cp, r0, r1};
data->Initialize(arraysize(registers), registers, NULL);
}
+
+
+void AllocateHeapNumberDescriptor::Initialize(
+ CallInterfaceDescriptorData* data) {
+ // register state
+ // cp -- context
+ Register registers[] = {cp};
+ data->Initialize(arraysize(registers), registers, nullptr);
+}
void ArrayConstructorConstantArgCountDescriptor::Initialize(
=======================================
--- /branches/bleeding_edge/src/arm64/interface-descriptors-arm64.cc Tue
Sep 30 14:54:14 2014 UTC
+++ /branches/bleeding_edge/src/arm64/interface-descriptors-arm64.cc Tue
Nov 4 12:58:17 2014 UTC
@@ -183,6 +183,14 @@
Register registers[] = {cp, x0, x1};
data->Initialize(arraysize(registers), registers, NULL);
}
+
+
+void AllocateHeapNumberDescriptor::Initialize(
+ CallInterfaceDescriptorData* data) {
+ // cp: context
+ Register registers[] = {cp};
+ data->Initialize(arraysize(registers), registers, nullptr);
+}
void ArrayConstructorConstantArgCountDescriptor::Initialize(
=======================================
--- /branches/bleeding_edge/src/code-factory.cc Fri Oct 10 09:49:43 2014 UTC
+++ /branches/bleeding_edge/src/code-factory.cc Tue Nov 4 12:58:17 2014 UTC
@@ -101,6 +101,13 @@
StringAddStub stub(isolate, flags, pretenure_flag);
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
}
+
+
+// static
+Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
+ AllocateHeapNumberStub stub(isolate);
+ return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
+}
// static
=======================================
--- /branches/bleeding_edge/src/code-factory.h Fri Oct 10 09:49:43 2014 UTC
+++ /branches/bleeding_edge/src/code-factory.h Tue Nov 4 12:58:17 2014 UTC
@@ -55,9 +55,13 @@
static Callable StringAdd(Isolate* isolate, StringAddFlags flags,
PretenureFlag pretenure_flag);
+ static Callable AllocateHeapNumber(Isolate* isolate);
+
static Callable CallFunction(Isolate* isolate, int argc,
CallFunctionFlags flags);
};
-}
-}
+
+} // namespace internal
+} // namespace v8
+
#endif // V8_CODE_FACTORY_H_
=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Tue Nov 4 11:40:21
2014 UTC
+++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Tue Nov 4 12:58:17
2014 UTC
@@ -882,6 +882,22 @@
Handle<Code> TransitionElementsKindStub::GenerateCode() {
return DoGenerateCode(this);
}
+
+
+template <>
+HValue* CodeStubGraphBuilder<AllocateHeapNumberStub>::BuildCodeStub() {
+ HValue* result =
+ Add<HAllocate>(Add<HConstant>(HeapNumber::kSize),
HType::HeapNumber(),
+ NOT_TENURED, HEAP_NUMBER_TYPE);
+ AddStoreMapConstant(result, isolate()->factory()->heap_number_map());
+ return result;
+}
+
+
+Handle<Code> AllocateHeapNumberStub::GenerateCode() {
+ return DoGenerateCode(this);
+}
+
HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
ElementsKind kind,
=======================================
--- /branches/bleeding_edge/src/code-stubs.cc Mon Oct 13 07:50:21 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.cc Tue Nov 4 12:58:17 2014 UTC
@@ -695,6 +695,13 @@
descriptor->Initialize(
Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
}
+
+
+void AllocateHeapNumberStub::InitializeDescriptor(
+ CodeStubDescriptor* descriptor) {
+ descriptor->Initialize(
+ Runtime::FunctionForId(Runtime::kAllocateHeapNumber)->entry);
+}
void CompareNilICStub::InitializeDescriptor(CodeStubDescriptor*
descriptor) {
=======================================
--- /branches/bleeding_edge/src/code-stubs.h Wed Oct 29 18:31:01 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.h Tue Nov 4 12:58:17 2014 UTC
@@ -51,6 +51,7 @@
V(StubFailureTrampoline) \
V(SubString) \
/* HydrogenCodeStubs */ \
+ V(AllocateHeapNumber) \
V(ArrayNArgumentsConstructor) \
V(ArrayNoArgumentConstructor) \
V(ArraySingleArgumentConstructor) \
@@ -2113,6 +2114,17 @@
};
+class AllocateHeapNumberStub FINAL : public HydrogenCodeStub {
+ public:
+ explicit AllocateHeapNumberStub(Isolate* isolate)
+ : HydrogenCodeStub(isolate) {}
+
+ private:
+ DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateHeapNumber);
+ DEFINE_HYDROGEN_CODE_STUB(AllocateHeapNumber, HydrogenCodeStub);
+};
+
+
class ArrayConstructorStubBase : public HydrogenCodeStub {
public:
ArrayConstructorStubBase(Isolate* isolate,
=======================================
--- /branches/bleeding_edge/src/compiler/change-lowering.cc Tue Nov 4
12:06:23 2014 UTC
+++ /branches/bleeding_edge/src/compiler/change-lowering.cc Tue Nov 4
12:58:17 2014 UTC
@@ -4,6 +4,7 @@
#include "src/compiler/change-lowering.h"
+#include "src/code-factory.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h"
#include "src/compiler/machine-operator.h"
@@ -66,19 +67,16 @@
Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node*
control) {
- // The AllocateHeapNumber() runtime function does not use the context,
so we
- // can safely pass in Smi zero here.
+ // The AllocateHeapNumberStub does not use the context, so we can safely
pass
+ // in Smi zero here.
+ Callable callable = CodeFactory::AllocateHeapNumber(isolate());
+ CallDescriptor* descriptor = linkage()->GetStubCallDescriptor(
+ callable.descriptor(), 0, CallDescriptor::kNoFlags);
+ Node* target = jsgraph()->HeapConstant(callable.code());
Node* context = jsgraph()->ZeroConstant();
Node* effect = graph()->NewNode(common()->ValueEffect(1), value);
- const Runtime::Function* function =
- Runtime::FunctionForId(Runtime::kAllocateHeapNumber);
- DCHECK_EQ(0, function->nargs);
- CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor(
- function->function_id, 0, Operator::kNoProperties);
- Node* heap_number = graph()->NewNode(
- common()->Call(desc), jsgraph()->CEntryStubConstant(),
- jsgraph()->ExternalConstant(ExternalReference(function, isolate())),
- jsgraph()->Int32Constant(function->nargs), context, effect, control);
+ Node* heap_number = graph()->NewNode(common()->Call(descriptor), target,
+ context, effect, control);
Node* store = graph()->NewNode(
machine()->Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier)),
heap_number, HeapNumberValueIndexConstant(), value, heap_number,
control);
=======================================
--- /branches/bleeding_edge/src/ia32/interface-descriptors-ia32.cc Tue Sep
30 14:54:14 2014 UTC
+++ /branches/bleeding_edge/src/ia32/interface-descriptors-ia32.cc Tue Nov
4 12:58:17 2014 UTC
@@ -153,6 +153,15 @@
Register registers[] = {esi, eax, ebx};
data->Initialize(arraysize(registers), registers, NULL);
}
+
+
+void AllocateHeapNumberDescriptor::Initialize(
+ CallInterfaceDescriptorData* data) {
+ // register state
+ // esi -- context
+ Register registers[] = {esi};
+ data->Initialize(arraysize(registers), registers, nullptr);
+}
void ArrayConstructorConstantArgCountDescriptor::Initialize(
=======================================
--- /branches/bleeding_edge/src/interface-descriptors.h Thu Oct 30 09:00:58
2014 UTC
+++ /branches/bleeding_edge/src/interface-descriptors.h Tue Nov 4 12:58:17
2014 UTC
@@ -33,6 +33,7 @@
V(CallConstruct) \
V(RegExpConstructResult) \
V(TransitionElementsKind) \
+ V(AllocateHeapNumber) \
V(ArrayConstructorConstantArgCount) \
V(ArrayConstructor) \
V(InternalArrayConstructorConstantArgCount) \
@@ -346,6 +347,12 @@
};
+class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
+ public:
+ DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor)
+};
+
+
class ArrayConstructorConstantArgCountDescriptor
: public CallInterfaceDescriptor {
public:
=======================================
--- /branches/bleeding_edge/src/x64/interface-descriptors-x64.cc Tue Sep 30
14:54:14 2014 UTC
+++ /branches/bleeding_edge/src/x64/interface-descriptors-x64.cc Tue Nov 4
12:58:17 2014 UTC
@@ -153,6 +153,15 @@
Register registers[] = {rsi, rax, rbx};
data->Initialize(arraysize(registers), registers, NULL);
}
+
+
+void AllocateHeapNumberDescriptor::Initialize(
+ CallInterfaceDescriptorData* data) {
+ // register state
+ // rsi -- context
+ Register registers[] = {rsi};
+ data->Initialize(arraysize(registers), registers, nullptr);
+}
void ArrayConstructorConstantArgCountDescriptor::Initialize(
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
Mon Nov 3 10:04:37 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
Tue Nov 4 12:58:17 2014 UTC
@@ -79,13 +79,9 @@
Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher,
const Matcher<Node*>&
control_matcher) {
- return IsCall(
- _, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
- CEntryStub(isolate(), 1).GetCode())),
- IsExternalConstant(ExternalReference(
- Runtime::FunctionForId(Runtime::kAllocateHeapNumber),
isolate())),
- IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher,
- control_matcher);
+ return IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
+ AllocateHeapNumberStub(isolate()).GetCode())),
+ IsNumberConstant(0.0), effect_matcher, control_matcher);
}
Matcher<Node*> IsLoadHeapNumber(const Matcher<Node*>& value_matcher,
const Matcher<Node*>& control_matcher) {
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/node-test-utils.cc Thu
Oct 30 14:15:20 2014 UTC
+++ /branches/bleeding_edge/test/unittests/compiler/node-test-utils.cc Tue
Nov 4 12:58:17 2014 UTC
@@ -332,15 +332,66 @@
};
-class IsCallMatcher FINAL : public NodeMatcher {
+class IsCall2Matcher FINAL : public NodeMatcher {
public:
- IsCallMatcher(const Matcher<CallDescriptor*>& descriptor_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& value2_matcher,
- const Matcher<Node*>& value3_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher)
+ IsCall2Matcher(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kCall),
+ descriptor_matcher_(descriptor_matcher),
+ value0_matcher_(value0_matcher),
+ value1_matcher_(value1_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose value0 (";
+ value0_matcher_.DescribeTo(os);
+ *os << ") and value1 (";
+ value1_matcher_.DescribeTo(os);
+ *os << ") and effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(OpParameter<CallDescriptor*>(node),
+ "descriptor", descriptor_matcher_,
listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
+ "value0", value0_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "value1", value1_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<CallDescriptor*> descriptor_matcher_;
+ const Matcher<Node*> value0_matcher_;
+ const Matcher<Node*> value1_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsCall4Matcher FINAL : public NodeMatcher {
+ public:
+ IsCall4Matcher(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& value2_matcher,
+ const Matcher<Node*>& value3_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
: NodeMatcher(IrOpcode::kCall),
descriptor_matcher_(descriptor_matcher),
value0_matcher_(value0_matcher),
@@ -833,6 +884,17 @@
const Matcher<Node*>& base_matcher) {
return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
}
+
+
+Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsCall2Matcher(descriptor_matcher, value0_matcher,
+ value1_matcher, effect_matcher,
+ control_matcher));
+}
Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
@@ -842,7 +904,7 @@
const Matcher<Node*>& value3_matcher,
const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsCallMatcher(
+ return MakeMatcher(new IsCall4Matcher(
descriptor_matcher, value0_matcher, value1_matcher, value2_matcher,
value3_matcher, effect_matcher, control_matcher));
}
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/node-test-utils.h Thu
Oct 30 14:15:20 2014 UTC
+++ /branches/bleeding_edge/test/unittests/compiler/node-test-utils.h Tue
Nov 4 12:58:17 2014 UTC
@@ -58,6 +58,11 @@
const Matcher<Node*>& merge_matcher);
Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
const Matcher<Node*>& base_matcher);
+Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher);
Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
const Matcher<Node*>& value0_matcher,
const Matcher<Node*>& value1_matcher,
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.