From: mstarzinger@chromium.org Date: Thu, 28 Aug 2014 17:53:24 +0000 (+0000) Subject: Move constructors for [Element/Field]Access into AccessBuilder. X-Git-Tag: upstream/4.7.83~7293 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0ea36cb5b6945287861d1bdee2cfa783a42ee85;p=platform%2Fupstream%2Fv8.git Move constructors for [Element/Field]Access into AccessBuilder. R=titzer@chromium.org TEST=cctest/test-simplified-lowering Review URL: https://codereview.chromium.org/516943002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23501 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/compiler/access-builder.h b/src/compiler/access-builder.h index a22df9d..b300330 100644 --- a/src/compiler/access-builder.h +++ b/src/compiler/access-builder.h @@ -16,18 +16,47 @@ namespace compiler { // parameters to simplified load/store operators. class AccessBuilder : public AllStatic { public: + // Provides access to HeapObject::map() field. + static FieldAccess ForMap() { + return {kTaggedBase, HeapObject::kMapOffset, Handle(), Type::Any(), + kMachAnyTagged}; + } + + // Provides access to JSObject::properties() field. + static FieldAccess ForJSObjectProperties() { + return {kTaggedBase, JSObject::kPropertiesOffset, Handle(), + Type::Any(), kMachAnyTagged}; + } + // Provides access to JSObject::elements() field. static FieldAccess ForJSObjectElements() { return {kTaggedBase, JSObject::kElementsOffset, Handle(), Type::Internal(), kMachAnyTagged}; } + // Provides access to JSArrayBuffer::backing_store() field. + static FieldAccess ForJSArrayBufferBackingStore() { + return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle(), + Type::UntaggedPtr(), kMachPtr}; + } + // Provides access to ExternalArray::external_pointer() field. static FieldAccess ForExternalArrayPointer() { return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle(), Type::UntaggedPtr(), kMachPtr}; } + // Provides access to FixedArray elements. + static ElementAccess ForFixedArrayElement() { + return {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged}; + } + + // TODO(mstarzinger): Raw access only for testing, drop me. + static ElementAccess ForBackingStoreElement(MachineType rep) { + return {kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, + Type::Any(), rep}; + } + // Provides access to Fixed{type}TypedArray and External{type}Array elements. static ElementAccess ForTypedArrayElement(ExternalArrayType type, bool is_external) { diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc index 4c86e40..cce2a82 100644 --- a/test/cctest/compiler/test-simplified-lowering.cc +++ b/test/cctest/compiler/test-simplified-lowering.cc @@ -4,6 +4,7 @@ #include +#include "src/compiler/access-builder.h" #include "src/compiler/control-builders.h" #include "src/compiler/generic-node-inl.h" #include "src/compiler/graph-visualizer.h" @@ -53,48 +54,6 @@ class SimplifiedLoweringTester : public GraphBuilderTester { }; -// TODO(dcarney): find a home for these functions. -namespace { - -FieldAccess ForJSObjectMap() { - FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle(), - Type::Any(), kMachAnyTagged}; - return access; -} - - -FieldAccess ForJSObjectProperties() { - FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset, - Handle(), Type::Any(), kMachAnyTagged}; - return access; -} - - -FieldAccess ForArrayBufferBackingStore() { - FieldAccess access = { - kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle(), - Type::UntaggedPtr(), kMachPtr, - }; - return access; -} - - -ElementAccess ForFixedArrayElement() { - ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), - kMachAnyTagged}; - return access; -} - - -ElementAccess ForBackingStoreElement(MachineType rep) { - ElementAccess access = {kUntaggedBase, - kNonHeapObjectHeaderSize - kHeapObjectTag, - Type::Any(), rep}; - return access; -} -} - - #ifndef V8_TARGET_ARCH_ARM64 // TODO(titzer): these result in a stub call that doesn't work on ARM64. // TODO(titzer): factor these tests out to test-run-simplifiedops.cc. @@ -166,7 +125,7 @@ static Handle TestObject() { TEST(RunLoadMap) { SimplifiedLoweringTester t(kMachAnyTagged); - FieldAccess access = ForJSObjectMap(); + FieldAccess access = AccessBuilder::ForMap(); Node* load = t.LoadField(access, t.Parameter(0)); t.Return(load); @@ -184,7 +143,7 @@ TEST(RunLoadMap) { TEST(RunStoreMap) { SimplifiedLoweringTester t(kMachAnyTagged, kMachAnyTagged); - FieldAccess access = ForJSObjectMap(); + FieldAccess access = AccessBuilder::ForMap(); t.StoreField(access, t.Parameter(1), t.Parameter(0)); t.Return(t.jsgraph.TrueConstant()); @@ -204,7 +163,7 @@ TEST(RunStoreMap) { TEST(RunLoadProperties) { SimplifiedLoweringTester t(kMachAnyTagged); - FieldAccess access = ForJSObjectProperties(); + FieldAccess access = AccessBuilder::ForJSObjectProperties(); Node* load = t.LoadField(access, t.Parameter(0)); t.Return(load); @@ -222,7 +181,7 @@ TEST(RunLoadProperties) { TEST(RunLoadStoreMap) { SimplifiedLoweringTester t(kMachAnyTagged, kMachAnyTagged); - FieldAccess access = ForJSObjectMap(); + FieldAccess access = AccessBuilder::ForMap(); Node* load = t.LoadField(access, t.Parameter(0)); t.StoreField(access, t.Parameter(1), load); t.Return(load); @@ -245,7 +204,7 @@ TEST(RunLoadStoreMap) { TEST(RunLoadStoreFixedArrayIndex) { SimplifiedLoweringTester t(kMachAnyTagged); - ElementAccess access = ForFixedArrayElement(); + ElementAccess access = AccessBuilder::ForFixedArrayElement(); Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0)); t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load); t.Return(load); @@ -270,9 +229,10 @@ TEST(RunLoadStoreFixedArrayIndex) { TEST(RunLoadStoreArrayBuffer) { SimplifiedLoweringTester t(kMachAnyTagged); const int index = 12; - ElementAccess buffer_access = ForBackingStoreElement(kMachInt8); - Node* backing_store = - t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0)); + ElementAccess buffer_access = + AccessBuilder::ForBackingStoreElement(kMachInt8); + Node* backing_store = t.LoadField( + AccessBuilder::ForJSArrayBufferBackingStore(), t.Parameter(0)); Node* load = t.LoadElement(buffer_access, backing_store, t.Int32Constant(index)); t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1),