Reviewers: dcarney,
Message:
PTAL
Description:
[turbofan] Embed the actual backing store address for typed loads/stores.
TEST=unittests
Please review this at https://codereview.chromium.org/650843002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+56, -43 lines):
M src/compiler/common-node-cache.h
M src/compiler/js-graph.h
M src/compiler/js-graph.cc
M src/compiler/js-typed-lowering.cc
M test/unittests/compiler/js-typed-lowering-unittest.cc
Index: src/compiler/common-node-cache.h
diff --git a/src/compiler/common-node-cache.h
b/src/compiler/common-node-cache.h
index
1ed2b0497dbc1b06830ee43aa0c7ba22a64e67d6..ca43325e52ad439f3ded704e13ae82e35b336385
100644
--- a/src/compiler/common-node-cache.h
+++ b/src/compiler/common-node-cache.h
@@ -21,6 +21,10 @@ class CommonNodeCache FINAL : public ZoneObject {
return int32_constants_.Find(zone_, value);
}
+ Node** FindInt64Constant(int64_t value) {
+ return int64_constants_.Find(zone_, value);
+ }
+
Node** FindFloat64Constant(double value) {
// We canonicalize double constants at the bit representation level.
return float64_constants_.Find(zone_, bit_cast<int64_t>(value));
@@ -39,13 +43,15 @@ class CommonNodeCache FINAL : public ZoneObject {
private:
Int32NodeCache int32_constants_;
+ Int64NodeCache int64_constants_;
Int64NodeCache float64_constants_;
PtrNodeCache external_constants_;
Int64NodeCache number_constants_;
Zone* zone_;
};
-}
-}
-} // namespace v8::internal::compiler
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
#endif // V8_COMPILER_COMMON_NODE_CACHE_H_
Index: src/compiler/js-graph.cc
diff --git a/src/compiler/js-graph.cc b/src/compiler/js-graph.cc
index
6105dfe7050962c50328fbc423ecd1e0c94d4f26..fef6a074f0e4e7c65f904c844d1521c581f0bc1e
100644
--- a/src/compiler/js-graph.cc
+++ b/src/compiler/js-graph.cc
@@ -157,6 +157,15 @@ Node* JSGraph::Int32Constant(int32_t value) {
}
+Node* JSGraph::Int64Constant(int64_t value) {
+ Node** loc = cache_.FindInt64Constant(value);
+ if (*loc == NULL) {
+ *loc = NewNode(common()->Int64Constant(value));
+ }
+ return *loc;
+}
+
+
Node* JSGraph::NumberConstant(double value) {
Node** loc = cache_.FindNumberConstant(value);
if (*loc == NULL) {
@@ -188,6 +197,7 @@ Node* JSGraph::ExternalConstant(ExternalReference
reference) {
}
return *loc;
}
+
} // namespace compiler
} // namespace internal
} // namespace v8
Index: src/compiler/js-graph.h
diff --git a/src/compiler/js-graph.h b/src/compiler/js-graph.h
index
31e9c48a65383440c09f58ad0c3b4c595e365b9f..37f16ee50706ce487a5c0e60a2e1ec02cb01b3b1
100644
--- a/src/compiler/js-graph.h
+++ b/src/compiler/js-graph.h
@@ -69,6 +69,19 @@ class JSGraph : public ZoneObject {
return Int32Constant(bit_cast<int32_t>(value));
}
+ // Creates a Int64Constant node, usually canonicalized.
+ Node* Int64Constant(int64_t value);
+ Node* Uint64Constant(uint64_t value) {
+ return Int64Constant(bit_cast<int64_t>(value));
+ }
+
+ // Creates a Int32Constant/Int64Constant node, depending on the word
size of
+ // the target machine.
+ Node* IntPtrConstant(intptr_t value) {
+ return machine()->Is32() ? Int32Constant(static_cast<int32_t>(value))
+ : Int64Constant(static_cast<int64_t>(value));
+ }
+
// Creates a Float32Constant node, usually canonicalized.
Node* Float32Constant(float value);
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc
b/src/compiler/js-typed-lowering.cc
index
557b0278be8ac653df3eb34f1471d2d0099d5d97..886846eaddd193a13b9fab13e81176f00da2b615
100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -543,12 +543,10 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node*
node) {
ExternalArrayType type = array->type();
uint32_t byte_length;
if (array->byte_length()->ToUint32(&byte_length)) {
- Node* elements = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForJSObjectElements()),
base,
- graph()->start());
- Node* pointer = graph()->NewNode(
-
simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()),
- elements, elements);
+ Handle<ExternalArray> elements =
+ Handle<ExternalArray>::cast(handle(array->elements()));
+ Node* pointer = jsgraph()->IntPtrConstant(
+ bit_cast<intptr_t>(elements->external_pointer()));
Node* length = jsgraph()->Uint32Constant(
static_cast<uint32_t>(byte_length / array->element_size()));
Node* effect = NodeProperties::GetEffectInput(node);
@@ -582,12 +580,10 @@ Reduction
JSTypedLowering::ReduceJSStoreProperty(Node* node) {
ExternalArrayType type = array->type();
uint32_t byte_length;
if (array->byte_length()->ToUint32(&byte_length)) {
- Node* elements = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForJSObjectElements()),
base,
- graph()->start());
- Node* pointer = graph()->NewNode(
-
simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()),
- elements, elements);
+ Handle<ExternalArray> elements =
+ Handle<ExternalArray>::cast(handle(array->elements()));
+ Node* pointer = jsgraph()->IntPtrConstant(
+ bit_cast<intptr_t>(elements->external_pointer()));
Node* length = jsgraph()->Uint32Constant(
static_cast<uint32_t>(byte_length / array->element_size()));
Node* effect = NodeProperties::GetEffectInput(node);
Index: test/unittests/compiler/js-typed-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc
b/test/unittests/compiler/js-typed-lowering-unittest.cc
index
bba4d653321d6228d52b1b88f280d7985e04fa34..a52626f6f4a40436242c9fb50c4168f4ed980bb0
100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -11,12 +11,7 @@
#include "src/compiler/typer.h"
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/graph-unittest.h"
-#include "testing/gmock-support.h"
-
-using testing::_;
-using testing::AllOf;
-using testing::Capture;
-using testing::CaptureEq;
+#include "testing/gtest-support.h"
namespace v8 {
namespace internal {
@@ -62,6 +57,11 @@ class JSTypedLoweringTest : public GraphTest {
return buffer;
}
+ Matcher<Node*> IsIntPtrConstant(intptr_t value) {
+ return sizeof(value) == 4 ?
IsInt32Constant(static_cast<int32_t>(value))
+ :
IsInt64Constant(static_cast<int64_t>(value));
+ }
+
JSOperatorBuilder* javascript() { return &javascript_; }
private:
@@ -98,18 +98,13 @@ TEST_F(JSTypedLoweringTest,
JSLoadPropertyFromExternalTypedArray) {
node->AppendInput(zone(), control);
Reduction r = Reduce(node);
- Capture<Node*> elements;
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
- IsLoadElement(
- AccessBuilder::ForTypedArrayElement(type, true),
- IsLoadField(AccessBuilder::ForExternalArrayPointer(),
- AllOf(CaptureEq(&elements),
-
IsLoadField(AccessBuilder::ForJSObjectElements(),
- base, _)),
- CaptureEq(&elements)),
- key, IsInt32Constant(static_cast<int>(kLength)), effect,
control));
+ IsLoadElement(AccessBuilder::ForTypedArrayElement(type, true),
+
IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
+ key, IsInt32Constant(static_cast<int>(kLength)),
effect,
+ control));
}
}
@@ -143,20 +138,13 @@ TEST_F(JSTypedLoweringTest,
JSStorePropertyToExternalTypedArray) {
node->AppendInput(zone(), control);
Reduction r = Reduce(node);
- Capture<Node*> elements;
ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsStoreElement(
- AccessBuilder::ForTypedArrayElement(type, true),
- IsLoadField(
- AccessBuilder::ForExternalArrayPointer(),
- AllOf(CaptureEq(&elements),
- IsLoadField(AccessBuilder::ForJSObjectElements(),
base,
- _)),
- CaptureEq(&elements)),
- key, IsInt32Constant(static_cast<int>(kLength)), value,
effect,
- control));
+ EXPECT_THAT(r.replacement(),
+ IsStoreElement(
+ AccessBuilder::ForTypedArrayElement(type, true),
+
IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
+ key, IsInt32Constant(static_cast<int>(kLength)),
value,
+ effect, control));
}
}
}
--
--
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/d/optout.