Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 1224083002: Revert of [turbofan] Optimize string "length" property access based on types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/compiler/string-length.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 EXPECT_THAT( 867 EXPECT_THAT(
868 r.replacement(), 868 r.replacement(),
869 IsStoreElement( 869 IsStoreElement(
870 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 870 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
871 key, value, effect, control)); 871 key, value, effect, control));
872 } 872 }
873 } 873 }
874 } 874 }
875 875
876 876
877 // ----------------------------------------------------------------------------- 877 TEST_F(JSTypedLoweringTest, JSLoadNamedGlobalConstants) {
878 // JSLoadGlobal
879
880
881 TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) {
882 Handle<String> names[] = { 878 Handle<String> names[] = {
883 Handle<String>(isolate()->heap()->undefined_string(), isolate()), 879 Handle<String>(isolate()->heap()->undefined_string(), isolate()),
884 Handle<String>(isolate()->heap()->infinity_string(), isolate()), 880 Handle<String>(isolate()->heap()->infinity_string(), isolate()),
885 Handle<String>(isolate()->heap()->nan_string(), isolate()) // -- 881 Handle<String>(isolate()->heap()->nan_string(), isolate()) // --
886 }; 882 };
887 Matcher<Node*> matches[] = { 883 Matcher<Node*> matches[] = {
888 IsHeapConstant(Unique<HeapObject>::CreateImmovable( 884 IsHeapConstant(Unique<HeapObject>::CreateImmovable(
889 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()))), 885 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()))),
890 IsNumberConstant(std::numeric_limits<double>::infinity()), 886 IsNumberConstant(std::numeric_limits<double>::infinity()),
891 IsNumberConstant(IsNaN()) // -- 887 IsNumberConstant(IsNaN()) // --
(...skipping 10 matching lines...) Expand all
902 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]); 898 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
903 Reduction r = Reduce(graph()->NewNode( 899 Reduction r = Reduce(graph()->NewNode(
904 javascript()->LoadGlobal(name, feedback), global, vector, context, 900 javascript()->LoadGlobal(name, feedback), global, vector, context,
905 EmptyFrameState(), EmptyFrameState(), effect, control)); 901 EmptyFrameState(), EmptyFrameState(), effect, control));
906 902
907 ASSERT_TRUE(r.Changed()); 903 ASSERT_TRUE(r.Changed());
908 EXPECT_THAT(r.replacement(), matches[i]); 904 EXPECT_THAT(r.replacement(), matches[i]);
909 } 905 }
910 } 906 }
911 907
912
913 // -----------------------------------------------------------------------------
914 // JSLoadNamed
915
916
917 TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) {
918 VectorSlotPair feedback;
919 Unique<Name> name = Unique<Name>::CreateImmovable(factory()->length_string());
920 Node* const receiver = Parameter(Type::String(), 0);
921 Node* const vector = Parameter(Type::Internal(), 1);
922 Node* const context = UndefinedConstant();
923 Node* const effect = graph()->start();
924 Node* const control = graph()->start();
925 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
926 Reduction const r = Reduce(
927 graph()->NewNode(javascript()->LoadNamed(name, feedback, language_mode),
928 receiver, vector, context, EmptyFrameState(),
929 EmptyFrameState(), effect, control));
930 ASSERT_TRUE(r.Changed());
931 EXPECT_THAT(r.replacement(),
932 IsLoadField(AccessBuilder::ForStringLength(zone()), receiver,
933 effect, control));
934 }
935 }
936
937 908
938 // ----------------------------------------------------------------------------- 909 // -----------------------------------------------------------------------------
939 // JSLoadDynamicGlobal 910 // JSLoadDynamicGlobal
940 911
941 912
942 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { 913 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) {
943 Node* const context = Parameter(Type::Any()); 914 Node* const context = Parameter(Type::Any());
944 Node* const vector = UndefinedConstant(); 915 Node* const vector = UndefinedConstant();
945 Node* const frame_state = EmptyFrameState(); 916 Node* const frame_state = EmptyFrameState();
946 Node* const effect = graph()->start(); 917 Node* const effect = graph()->start();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 EXPECT_THAT(r.replacement(), 1096 EXPECT_THAT(r.replacement(),
1126 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( 1097 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor(
1127 Context::MIN_CONTEXT_SLOTS)), 1098 Context::MIN_CONTEXT_SLOTS)),
1128 effect, control), 1099 effect, control),
1129 _)); 1100 _));
1130 } 1101 }
1131 1102
1132 } // namespace compiler 1103 } // namespace compiler
1133 } // namespace internal 1104 } // namespace internal
1134 } // namespace v8 1105 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/string-length.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698