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

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

Issue 1412683011: [Interpreter] Enable assignments in expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Sync test bytecode sequences to avoid unnecessary Ldar/Star instructions. Created 5 years, 1 month 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 | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('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 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 // TODO(rmcilroy): Remove this define after this flag is turned on globally 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 5247 matching lines...) Expand 10 before | Expand all | Expand 10 after
5258 }}, 5258 }},
5259 }; 5259 };
5260 5260
5261 for (size_t i = 0; i < arraysize(snippets); i++) { 5261 for (size_t i = 0; i < arraysize(snippets); i++) {
5262 Handle<BytecodeArray> bytecode_array = 5262 Handle<BytecodeArray> bytecode_array =
5263 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 5263 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
5264 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5264 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5265 } 5265 }
5266 } 5266 }
5267 5267
5268
5269 TEST(AssignmentsInBinaryExpression) {
5270 InitializedHandleScope handle_scope;
5271 BytecodeGeneratorHelper helper;
5272
5273 ExpectedSnippet<const char*> snippets[] = {
5274 {"var x = 0, y = 1;\n"
5275 "return (x = 2, y = 3, x = 4, y = 5)",
5276 2 * kPointerSize,
5277 1,
5278 24,
5279 {
5280 B(LdaZero), B(Star), R(0), //
5281 B(LdaSmi8), U8(1), //
5282 B(Star), R(1), //
5283 B(LdaSmi8), U8(2), //
5284 B(Star), R(0), //
5285 B(LdaSmi8), U8(3), //
5286 B(Star), R(1), //
5287 B(LdaSmi8), U8(4), //
5288 B(Star), R(0), //
5289 B(LdaSmi8), U8(5), //
5290 B(Star), R(1), //
5291 B(Return), //
5292 },
5293 0},
5294 {"var x = 55;\n"
5295 "var y = (x = 100);\n"
5296 "return y",
5297 2 * kPointerSize,
5298 1,
5299 11,
5300 {
5301 B(LdaSmi8), U8(55), //
5302 B(Star), R(0), //
5303 B(LdaSmi8), U8(100), //
5304 B(Star), R(0), //
5305 B(Star), R(1), //
5306 B(Return), //
5307 },
5308 0},
5309 {"var x = 55;\n"
5310 "x = x + (x = 100) + (x = 101);\n"
5311 "return x;",
5312 4 * kPointerSize,
5313 1,
5314 24,
5315 {
5316 B(LdaSmi8), U8(55), //
5317 B(Star), R(0), //
5318 B(LdaSmi8), U8(100), //
5319 B(Star), R(1), //
5320 B(Add), R(0), //
5321 B(Star), R(2), //
5322 B(LdaSmi8), U8(101), //
5323 B(Star), R(3), //
5324 B(Add), R(2), //
5325 B(Mov), R(3), R(0), //
5326 B(Star), R(0), //
5327 B(Return), //
5328 },
5329 0},
5330 {"var x = 55;\n"
5331 "x = (x = 56) - x + (x = 57);\n"
5332 "x++;\n"
5333 "return x;",
5334 3 * kPointerSize,
5335 1,
5336 34,
5337 {
5338 B(LdaSmi8), U8(55), //
5339 B(Star), R(0), //
5340 B(LdaSmi8), U8(56), //
5341 B(Star), R(0), //
5342 B(Star), R(1), //
5343 B(Ldar), R(0), //
5344 B(Sub), R(1), //
5345 B(Star), R(2), //
5346 B(LdaSmi8), U8(57), //
5347 B(Star), R(1), //
5348 B(Add), R(2), //
5349 B(Mov), R(1), R(0), //
5350 B(Star), R(0), //
5351 B(ToNumber), //
5352 B(Star), R(1), //
5353 B(Inc), //
5354 B(Star), R(0), //
5355 B(Return), //
5356 },
5357 0},
5358 {"var x = 55;\n"
5359 "var y = x + (x = 1) + (x = 2) + (x = 3);\n"
5360 "return y;",
5361 6 * kPointerSize,
5362 1,
5363 32,
5364 {
5365 B(LdaSmi8), U8(55), //
5366 B(Star), R(0), //
5367 B(LdaSmi8), U8(1), //
5368 B(Star), R(2), //
5369 B(Add), R(0), //
5370 B(Star), R(3), //
5371 B(LdaSmi8), U8(2), //
5372 B(Star), R(4), //
5373 B(Add), R(3), //
5374 B(Star), R(5), //
5375 B(LdaSmi8), U8(3), //
5376 B(Star), R(3), //
5377 B(Add), R(5), //
5378 B(Mov), R(3), R(0), //
5379 B(Star), R(1), //
5380 B(Return), //
5381 },
5382 0},
5383 {"var x = 55;\n"
5384 "var x = x + (x = 1) + (x = 2) + (x = 3);\n"
5385 "return x;",
5386 5 * kPointerSize,
5387 1,
5388 32,
5389 {
5390 B(LdaSmi8), U8(55), //
5391 B(Star), R(0), //
5392 B(LdaSmi8), U8(1), //
5393 B(Star), R(1), //
5394 B(Add), R(0), //
5395 B(Star), R(2), //
5396 B(LdaSmi8), U8(2), //
5397 B(Star), R(3), //
5398 B(Add), R(2), //
5399 B(Star), R(4), //
5400 B(LdaSmi8), U8(3), //
5401 B(Star), R(2), //
5402 B(Add), R(4), //
5403 B(Mov), R(2), R(0), //
5404 B(Star), R(0), //
5405 B(Return), //
5406 },
5407 0},
5408 {"var x = 10, y = 20;\n"
5409 "return x + (x = 1) + (x + 1) * (y = 2) + (y = 3) + (x = 4) + (y = 5) + "
5410 "y;\n",
5411 6 * kPointerSize,
5412 1,
5413 64,
5414 {
5415 B(LdaSmi8), U8(10), //
5416 B(Star), R(0), //
5417 B(LdaSmi8), U8(20), //
5418 B(Star), R(1), //
5419 B(LdaSmi8), U8(1), //
5420 B(Star), R(2), //
5421 B(Add), R(0), //
5422 B(Star), R(3), //
5423 B(LdaSmi8), U8(1), //
5424 B(Add), R(2), //
5425 B(Star), R(4), //
5426 B(LdaSmi8), U8(2), //
5427 B(Star), R(1), //
5428 B(Mul), R(4), //
5429 B(Add), R(3), //
5430 B(Star), R(4), //
5431 B(LdaSmi8), U8(3), //
5432 B(Star), R(1), //
5433 B(Add), R(4), //
5434 B(Star), R(3), //
5435 B(LdaSmi8), U8(4), //
5436 B(Star), R(4), //
5437 B(Add), R(3), //
5438 B(Star), R(5), //
5439 B(LdaSmi8), U8(5), //
5440 B(Star), R(1), //
5441 B(Add), R(5), //
5442 B(Star), R(3), //
5443 B(Ldar), R(1), //
5444 B(Add), R(3), //
5445 B(Mov), R(4), R(0), //
5446 B(Return), //
5447 },
5448 0},
5449 {"var x = 17;\n"
5450 "return 1 + x + (x++) + (++x);\n",
5451 5 * kPointerSize,
5452 1,
5453 40,
5454 {
5455 B(LdaSmi8), U8(17), //
5456 B(Star), R(0), //
5457 B(LdaSmi8), U8(1), //
5458 B(Star), R(1), //
5459 B(Ldar), R(0), //
5460 B(Add), R(1), //
5461 B(Star), R(2), //
5462 B(Ldar), R(0), //
5463 B(ToNumber), //
5464 B(Star), R(1), //
5465 B(Inc), //
5466 B(Star), R(3), //
5467 B(Ldar), R(1), //
5468 B(Add), R(2), //
5469 B(Star), R(4), //
5470 B(Ldar), R(3), //
5471 B(ToNumber), //
5472 B(Inc), //
5473 B(Star), R(1), //
5474 B(Add), R(4), //
5475 B(Mov), R(1), R(0), //
5476 B(Return), //
5477 },
5478 0}};
5479
5480 for (size_t i = 0; i < arraysize(snippets); i++) {
5481 Handle<BytecodeArray> bytecode_array =
5482 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
5483 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5484 }
5485 }
5486
5268 } // namespace interpreter 5487 } // namespace interpreter
5269 } // namespace internal 5488 } // namespace internal
5270 } // namespace v8 5489 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698