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

Side by Side Diff: runtime/vm/assembler_dbc_test.cc

Issue 2104093003: DBC: Implement OneByteStringFromCharCode and StringToCharCode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: LoadConstant Created 4 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 | « no previous file | runtime/vm/constants_dbc.h » ('j') | runtime/vm/intermediate_language_dbc.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // FP[-kParamEndSlotFromFp - 2]: value 140 // FP[-kParamEndSlotFromFp - 2]: value
141 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { 141 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
142 __ Frame(2); 142 __ Frame(2);
143 __ Move(0, -kParamEndSlotFromFp - 1); 143 __ Move(0, -kParamEndSlotFromFp - 1);
144 __ Move(1, -kParamEndSlotFromFp - 2); 144 __ Move(1, -kParamEndSlotFromFp - 2);
145 __ StoreField(0, GrowableObjectArray::data_offset() / kWordSize, 1); 145 __ StoreField(0, GrowableObjectArray::data_offset() / kWordSize, 1);
146 __ Return(0); 146 __ Return(0);
147 } 147 }
148 148
149 149
150 ASSEMBLER_TEST_GENERATE(OneByteStringFromCharCode, assembler) {
zra 2016/06/29 14:34:12 I've been copying the comment from constants_dbc.h
rmacnak 2016/06/29 16:44:16 Done.
151 __ Frame(2);
152 __ LoadConstant(0, Smi::ZoneHandle(Smi::New(65)));
153 __ OneByteStringFromCharCode(1, 0);
154 __ Return(1);
155 }
156
157
158 ASSEMBLER_TEST_RUN(OneByteStringFromCharCode, test) {
159 EXPECT_EQ(Symbols::New(Thread::Current(), "A"),
160 EXECUTE_TEST_CODE_OBJECT(test->code()).raw());
161 }
162
163
164 ASSEMBLER_TEST_GENERATE(StringToCharCode, assembler) {
165 __ Frame(2);
166 __ LoadConstant(0, String::ZoneHandle(String::New("A", Heap::kOld)));
167 __ StringToCharCode(1, 0);
168 __ Return(1);
169 }
170
171
172 ASSEMBLER_TEST_RUN(StringToCharCode, test) {
173 EXPECT_EQ(65, EXECUTE_TEST_CODE_INTPTR(test->code()));
174 }
175
176
177 ASSEMBLER_TEST_GENERATE(StringToCharCodeIllegalLength, assembler) {
178 __ Frame(2);
179 __ LoadConstant(0, String::ZoneHandle(String::New("AAA", Heap::kOld)));
180 __ StringToCharCode(1, 0);
181 __ Return(1);
182 }
183
184
185 ASSEMBLER_TEST_RUN(StringToCharCodeIllegalLength, test) {
186 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INTPTR(test->code()));
187 }
188
189
150 // - AddTOS; SubTOS; MulTOS; BitOrTOS; BitAndTOS; EqualTOS; LessThanTOS; 190 // - AddTOS; SubTOS; MulTOS; BitOrTOS; BitAndTOS; EqualTOS; LessThanTOS;
151 // GreaterThanTOS; 191 // GreaterThanTOS;
152 // 192 //
153 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are 193 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are
154 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true 194 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true
155 // then pops operands and pushes result on the stack and skips the next 195 // then pops operands and pushes result on the stack and skips the next
156 // instruction (which implements a slow path fallback). 196 // instruction (which implements a slow path fallback).
157 ASSEMBLER_TEST_GENERATE(AddTOS, assembler) { 197 ASSEMBLER_TEST_GENERATE(AddTOS, assembler) {
158 __ PushConstant(Smi::Handle(Smi::New(-42))); 198 __ PushConstant(Smi::Handle(Smi::New(-42)));
159 __ PushConstant(Smi::Handle(Smi::New(84))); 199 __ PushConstant(Smi::Handle(Smi::New(84)));
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 } 1671 }
1632 1672
1633 1673
1634 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) { 1674 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) {
1635 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 1675 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
1636 } 1676 }
1637 1677
1638 } // namespace dart 1678 } // namespace dart
1639 1679
1640 #endif // defined(TARGET_ARCH_DBC) 1680 #endif // defined(TARGET_ARCH_DBC)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/constants_dbc.h » ('j') | runtime/vm/intermediate_language_dbc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698