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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1399773002: [Interpreter] Adds logical and, logical or and comma operators to interpreter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 {"var x = 0; return x;", 229 {"var x = 0; return x;",
230 kPointerSize, 230 kPointerSize,
231 1, 231 1,
232 6, 232 6,
233 { 233 {
234 B(LdaZero), // 234 B(LdaZero), //
235 B(Star), R(0), // 235 B(Star), R(0), //
236 B(Ldar), R(0), // 236 B(Ldar), R(0), //
237 B(Return) // 237 B(Return) //
238 }, 238 },
239 0 239 0},
240 },
241 {"var x = 0; return x + 3;", 240 {"var x = 0; return x + 3;",
242 2 * kPointerSize, 241 2 * kPointerSize,
243 1, 242 1,
244 12, 243 12,
245 { 244 {
246 B(LdaZero), // 245 B(LdaZero), //
247 B(Star), R(0), // 246 B(Star), R(0), //
248 B(Ldar), R(0), // Easy to spot r1 not really needed here. 247 B(Ldar), R(0), // Easy to spot r1 not really needed here.
249 B(Star), R(1), // Dead store. 248 B(Star), R(1), // Dead store.
250 B(LdaSmi8), U8(3), // 249 B(LdaSmi8), U8(3), //
251 B(Add), R(1), // 250 B(Add), R(1), //
252 B(Return) // 251 B(Return) //
253 }, 252 },
254 0 253 0},
255 }}; 254 {"var x = 0; return (x, 3);",
255 2 * kPointerSize,
256 1,
257 10,
258 {
259 B(LdaZero), //
260 B(Star), R(0), //
261 B(Ldar), R(0), // Easy to spot r1 not really needed here.
262 B(Star), R(1), // Dead store.
263 B(LdaSmi8), U8(3), //
264 B(Return) //
265 },
266 0},
267 {"var x = 0; return x || 3;",
268 2 * kPointerSize,
269 1,
270 17,
271 {
272 B(LdaZero), //
273 B(Star), R(0), //
274 B(Ldar), R(0), //
275 B(Star), R(1), //
276 B(ToBoolean), //
277 B(JumpIfFalse), U8(6), //
278 B(Ldar), R(1), //
279 B(Jump), U8(4), //
280 B(LdaSmi8), U8(3), //
281 B(Return) //
282 },
283 0},
284 {"var x = 0; return x && 3;",
285 2 * kPointerSize,
286 1,
287 17,
288 {
289 B(LdaZero), //
290 B(Star), R(0), //
291 B(Ldar), R(0), //
292 B(Star), R(1), //
293 B(ToBoolean), //
294 B(JumpIfTrue), U8(6), //
295 B(Ldar), R(1), //
296 B(Jump), U8(4), //
297 B(LdaSmi8), U8(3), //
298 B(Return) //
299 },
300 0},
301 {"return 0 && 3;",
302 1 * kPointerSize,
303 1,
304 2,
305 {
306 B(LdaZero), //
307 B(Return) //
308 },
309 0},
310 {" return 1 || 3;",
311 1 * kPointerSize,
312 1,
313 3,
314 {
315 B(LdaSmi8), U8(1), //
316 B(Return) //
317 },
318 0}};
256 319
257 for (size_t i = 0; i < arraysize(snippets); i++) { 320 for (size_t i = 0; i < arraysize(snippets); i++) {
258 Handle<BytecodeArray> bytecode_array = 321 Handle<BytecodeArray> bytecode_array =
259 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 322 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
260 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 323 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
261 } 324 }
262 } 325 }
263 326
264 327
265 TEST(Parameters) { 328 TEST(Parameters) {
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 Handle<BytecodeArray> bytecode_array = 1734 Handle<BytecodeArray> bytecode_array =
1672 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 1735 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
1673 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1736 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1674 } 1737 }
1675 } 1738 }
1676 1739
1677 1740
1678 } // namespace interpreter 1741 } // namespace interpreter
1679 } // namespace internal 1742 } // namespace internal
1680 } // namespace v8 1743 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698