| OLD | NEW |
| 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/execution.h" | 7 #include "src/execution.h" |
| 8 #include "src/handles.h" | 8 #include "src/handles.h" |
| 9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
| 10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 DISALLOW_COPY_AND_ASSIGN(InterpreterTester); | 157 DISALLOW_COPY_AND_ASSIGN(InterpreterTester); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 | 160 |
| 161 TEST(InterpreterReturn) { | 161 TEST(InterpreterReturn) { |
| 162 HandleAndZoneScope handles; | 162 HandleAndZoneScope handles; |
| 163 Handle<Object> undefined_value = | 163 Handle<Object> undefined_value = |
| 164 handles.main_isolate()->factory()->undefined_value(); | 164 handles.main_isolate()->factory()->undefined_value(); |
| 165 | 165 |
| 166 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 166 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 167 builder.set_locals_count(0); | 167 0, 0); |
| 168 builder.set_context_count(0); | |
| 169 builder.set_parameter_count(1); | |
| 170 builder.Return(); | 168 builder.Return(); |
| 171 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 169 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 172 | 170 |
| 173 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 171 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 174 auto callable = tester.GetCallable<>(); | 172 auto callable = tester.GetCallable<>(); |
| 175 Handle<Object> return_val = callable().ToHandleChecked(); | 173 Handle<Object> return_val = callable().ToHandleChecked(); |
| 176 CHECK(return_val.is_identical_to(undefined_value)); | 174 CHECK(return_val.is_identical_to(undefined_value)); |
| 177 } | 175 } |
| 178 | 176 |
| 179 | 177 |
| 180 TEST(InterpreterLoadUndefined) { | 178 TEST(InterpreterLoadUndefined) { |
| 181 HandleAndZoneScope handles; | 179 HandleAndZoneScope handles; |
| 182 Handle<Object> undefined_value = | 180 Handle<Object> undefined_value = |
| 183 handles.main_isolate()->factory()->undefined_value(); | 181 handles.main_isolate()->factory()->undefined_value(); |
| 184 | 182 |
| 185 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 183 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 186 builder.set_locals_count(0); | 184 0, 0); |
| 187 builder.set_context_count(0); | |
| 188 builder.set_parameter_count(1); | |
| 189 builder.LoadUndefined().Return(); | 185 builder.LoadUndefined().Return(); |
| 190 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 186 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 191 | 187 |
| 192 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 188 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 193 auto callable = tester.GetCallable<>(); | 189 auto callable = tester.GetCallable<>(); |
| 194 Handle<Object> return_val = callable().ToHandleChecked(); | 190 Handle<Object> return_val = callable().ToHandleChecked(); |
| 195 CHECK(return_val.is_identical_to(undefined_value)); | 191 CHECK(return_val.is_identical_to(undefined_value)); |
| 196 } | 192 } |
| 197 | 193 |
| 198 | 194 |
| 199 TEST(InterpreterLoadNull) { | 195 TEST(InterpreterLoadNull) { |
| 200 HandleAndZoneScope handles; | 196 HandleAndZoneScope handles; |
| 201 Handle<Object> null_value = handles.main_isolate()->factory()->null_value(); | 197 Handle<Object> null_value = handles.main_isolate()->factory()->null_value(); |
| 202 | 198 |
| 203 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 199 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 204 builder.set_locals_count(0); | 200 0, 0); |
| 205 builder.set_context_count(0); | |
| 206 builder.set_parameter_count(1); | |
| 207 builder.LoadNull().Return(); | 201 builder.LoadNull().Return(); |
| 208 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 202 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 209 | 203 |
| 210 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 204 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 211 auto callable = tester.GetCallable<>(); | 205 auto callable = tester.GetCallable<>(); |
| 212 Handle<Object> return_val = callable().ToHandleChecked(); | 206 Handle<Object> return_val = callable().ToHandleChecked(); |
| 213 CHECK(return_val.is_identical_to(null_value)); | 207 CHECK(return_val.is_identical_to(null_value)); |
| 214 } | 208 } |
| 215 | 209 |
| 216 | 210 |
| 217 TEST(InterpreterLoadTheHole) { | 211 TEST(InterpreterLoadTheHole) { |
| 218 HandleAndZoneScope handles; | 212 HandleAndZoneScope handles; |
| 219 Handle<Object> the_hole_value = | 213 Handle<Object> the_hole_value = |
| 220 handles.main_isolate()->factory()->the_hole_value(); | 214 handles.main_isolate()->factory()->the_hole_value(); |
| 221 | 215 |
| 222 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 216 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 223 builder.set_locals_count(0); | 217 0, 0); |
| 224 builder.set_context_count(0); | |
| 225 builder.set_parameter_count(1); | |
| 226 builder.LoadTheHole().Return(); | 218 builder.LoadTheHole().Return(); |
| 227 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 219 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 228 | 220 |
| 229 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 221 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 230 auto callable = tester.GetCallable<>(); | 222 auto callable = tester.GetCallable<>(); |
| 231 Handle<Object> return_val = callable().ToHandleChecked(); | 223 Handle<Object> return_val = callable().ToHandleChecked(); |
| 232 CHECK(return_val.is_identical_to(the_hole_value)); | 224 CHECK(return_val.is_identical_to(the_hole_value)); |
| 233 } | 225 } |
| 234 | 226 |
| 235 | 227 |
| 236 TEST(InterpreterLoadTrue) { | 228 TEST(InterpreterLoadTrue) { |
| 237 HandleAndZoneScope handles; | 229 HandleAndZoneScope handles; |
| 238 Handle<Object> true_value = handles.main_isolate()->factory()->true_value(); | 230 Handle<Object> true_value = handles.main_isolate()->factory()->true_value(); |
| 239 | 231 |
| 240 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 232 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 241 builder.set_locals_count(0); | 233 0, 0); |
| 242 builder.set_context_count(0); | |
| 243 builder.set_parameter_count(1); | |
| 244 builder.LoadTrue().Return(); | 234 builder.LoadTrue().Return(); |
| 245 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 235 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 246 | 236 |
| 247 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 237 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 248 auto callable = tester.GetCallable<>(); | 238 auto callable = tester.GetCallable<>(); |
| 249 Handle<Object> return_val = callable().ToHandleChecked(); | 239 Handle<Object> return_val = callable().ToHandleChecked(); |
| 250 CHECK(return_val.is_identical_to(true_value)); | 240 CHECK(return_val.is_identical_to(true_value)); |
| 251 } | 241 } |
| 252 | 242 |
| 253 | 243 |
| 254 TEST(InterpreterLoadFalse) { | 244 TEST(InterpreterLoadFalse) { |
| 255 HandleAndZoneScope handles; | 245 HandleAndZoneScope handles; |
| 256 Handle<Object> false_value = handles.main_isolate()->factory()->false_value(); | 246 Handle<Object> false_value = handles.main_isolate()->factory()->false_value(); |
| 257 | 247 |
| 258 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 248 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 259 builder.set_locals_count(0); | 249 0, 0); |
| 260 builder.set_context_count(0); | |
| 261 builder.set_parameter_count(1); | |
| 262 builder.LoadFalse().Return(); | 250 builder.LoadFalse().Return(); |
| 263 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 251 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 264 | 252 |
| 265 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 253 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 266 auto callable = tester.GetCallable<>(); | 254 auto callable = tester.GetCallable<>(); |
| 267 Handle<Object> return_val = callable().ToHandleChecked(); | 255 Handle<Object> return_val = callable().ToHandleChecked(); |
| 268 CHECK(return_val.is_identical_to(false_value)); | 256 CHECK(return_val.is_identical_to(false_value)); |
| 269 } | 257 } |
| 270 | 258 |
| 271 | 259 |
| 272 TEST(InterpreterLoadLiteral) { | 260 TEST(InterpreterLoadLiteral) { |
| 273 HandleAndZoneScope handles; | 261 HandleAndZoneScope handles; |
| 274 i::Factory* factory = handles.main_isolate()->factory(); | 262 i::Factory* factory = handles.main_isolate()->factory(); |
| 275 | 263 |
| 276 // Small Smis. | 264 // Small Smis. |
| 277 for (int i = -128; i < 128; i++) { | 265 for (int i = -128; i < 128; i++) { |
| 278 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 266 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 279 builder.set_locals_count(0); | 267 0, 0); |
| 280 builder.set_context_count(0); | |
| 281 builder.set_parameter_count(1); | |
| 282 builder.LoadLiteral(Smi::FromInt(i)).Return(); | 268 builder.LoadLiteral(Smi::FromInt(i)).Return(); |
| 283 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 269 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 284 | 270 |
| 285 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 271 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 286 auto callable = tester.GetCallable<>(); | 272 auto callable = tester.GetCallable<>(); |
| 287 Handle<Object> return_val = callable().ToHandleChecked(); | 273 Handle<Object> return_val = callable().ToHandleChecked(); |
| 288 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(i)); | 274 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(i)); |
| 289 } | 275 } |
| 290 | 276 |
| 291 // Large Smis. | 277 // Large Smis. |
| 292 { | 278 { |
| 293 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 279 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 294 builder.set_locals_count(0); | 280 0, 0); |
| 295 builder.set_context_count(0); | |
| 296 builder.set_parameter_count(1); | |
| 297 builder.LoadLiteral(Smi::FromInt(0x12345678)).Return(); | 281 builder.LoadLiteral(Smi::FromInt(0x12345678)).Return(); |
| 298 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 282 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 299 | 283 |
| 300 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 284 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 301 auto callable = tester.GetCallable<>(); | 285 auto callable = tester.GetCallable<>(); |
| 302 Handle<Object> return_val = callable().ToHandleChecked(); | 286 Handle<Object> return_val = callable().ToHandleChecked(); |
| 303 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x12345678)); | 287 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x12345678)); |
| 304 } | 288 } |
| 305 | 289 |
| 306 // Heap numbers. | 290 // Heap numbers. |
| 307 { | 291 { |
| 308 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 292 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 309 builder.set_locals_count(0); | 293 0, 0); |
| 310 builder.set_context_count(0); | |
| 311 builder.set_parameter_count(1); | |
| 312 builder.LoadLiteral(factory->NewHeapNumber(-2.1e19)).Return(); | 294 builder.LoadLiteral(factory->NewHeapNumber(-2.1e19)).Return(); |
| 313 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 295 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 314 | 296 |
| 315 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 297 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 316 auto callable = tester.GetCallable<>(); | 298 auto callable = tester.GetCallable<>(); |
| 317 Handle<Object> return_val = callable().ToHandleChecked(); | 299 Handle<Object> return_val = callable().ToHandleChecked(); |
| 318 CHECK_EQ(i::HeapNumber::cast(*return_val)->value(), -2.1e19); | 300 CHECK_EQ(i::HeapNumber::cast(*return_val)->value(), -2.1e19); |
| 319 } | 301 } |
| 320 | 302 |
| 321 // Strings. | 303 // Strings. |
| 322 { | 304 { |
| 323 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 305 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 324 builder.set_locals_count(0); | 306 0, 0); |
| 325 builder.set_context_count(0); | |
| 326 builder.set_parameter_count(1); | |
| 327 Handle<i::String> string = factory->NewStringFromAsciiChecked("String"); | 307 Handle<i::String> string = factory->NewStringFromAsciiChecked("String"); |
| 328 builder.LoadLiteral(string).Return(); | 308 builder.LoadLiteral(string).Return(); |
| 329 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 309 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 330 | 310 |
| 331 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 311 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 332 auto callable = tester.GetCallable<>(); | 312 auto callable = tester.GetCallable<>(); |
| 333 Handle<Object> return_val = callable().ToHandleChecked(); | 313 Handle<Object> return_val = callable().ToHandleChecked(); |
| 334 CHECK(i::String::cast(*return_val)->Equals(*string)); | 314 CHECK(i::String::cast(*return_val)->Equals(*string)); |
| 335 } | 315 } |
| 336 } | 316 } |
| 337 | 317 |
| 338 | 318 |
| 339 TEST(InterpreterLoadStoreRegisters) { | 319 TEST(InterpreterLoadStoreRegisters) { |
| 340 HandleAndZoneScope handles; | 320 HandleAndZoneScope handles; |
| 341 Handle<Object> true_value = handles.main_isolate()->factory()->true_value(); | 321 Handle<Object> true_value = handles.main_isolate()->factory()->true_value(); |
| 342 for (int i = 0; i <= kMaxInt8; i++) { | 322 for (int i = 0; i <= kMaxInt8; i++) { |
| 343 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 323 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 344 builder.set_locals_count(i + 1); | 324 0, i + 1); |
| 345 builder.set_context_count(0); | |
| 346 builder.set_parameter_count(1); | |
| 347 Register reg(i); | 325 Register reg(i); |
| 348 builder.LoadTrue() | 326 builder.LoadTrue() |
| 349 .StoreAccumulatorInRegister(reg) | 327 .StoreAccumulatorInRegister(reg) |
| 350 .LoadFalse() | 328 .LoadFalse() |
| 351 .LoadAccumulatorWithRegister(reg) | 329 .LoadAccumulatorWithRegister(reg) |
| 352 .Return(); | 330 .Return(); |
| 353 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 331 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 354 | 332 |
| 355 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 333 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 356 auto callable = tester.GetCallable<>(); | 334 auto callable = tester.GetCallable<>(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 397 |
| 420 TEST(InterpreterShiftOpsSmi) { | 398 TEST(InterpreterShiftOpsSmi) { |
| 421 int lhs_inputs[] = {0, -17, -182, 1073741823, -1}; | 399 int lhs_inputs[] = {0, -17, -182, 1073741823, -1}; |
| 422 int rhs_inputs[] = {5, 2, 1, -1, -2, 0, 31, 32, -32, 64, 37}; | 400 int rhs_inputs[] = {5, 2, 1, -1, -2, 0, 31, 32, -32, 64, 37}; |
| 423 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { | 401 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { |
| 424 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { | 402 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { |
| 425 for (size_t o = 0; o < arraysize(kShiftOperators); o++) { | 403 for (size_t o = 0; o < arraysize(kShiftOperators); o++) { |
| 426 HandleAndZoneScope handles; | 404 HandleAndZoneScope handles; |
| 427 i::Factory* factory = handles.main_isolate()->factory(); | 405 i::Factory* factory = handles.main_isolate()->factory(); |
| 428 BytecodeArrayBuilder builder(handles.main_isolate(), | 406 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 429 handles.main_zone()); | 407 handles.main_zone(), 1, 0, 1); |
| 430 builder.set_locals_count(1); | |
| 431 builder.set_context_count(0); | |
| 432 builder.set_parameter_count(1); | |
| 433 Register reg(0); | 408 Register reg(0); |
| 434 int lhs = lhs_inputs[l]; | 409 int lhs = lhs_inputs[l]; |
| 435 int rhs = rhs_inputs[r]; | 410 int rhs = rhs_inputs[r]; |
| 436 builder.LoadLiteral(Smi::FromInt(lhs)) | 411 builder.LoadLiteral(Smi::FromInt(lhs)) |
| 437 .StoreAccumulatorInRegister(reg) | 412 .StoreAccumulatorInRegister(reg) |
| 438 .LoadLiteral(Smi::FromInt(rhs)) | 413 .LoadLiteral(Smi::FromInt(rhs)) |
| 439 .BinaryOperation(kShiftOperators[o], reg, Strength::WEAK) | 414 .BinaryOperation(kShiftOperators[o], reg, Strength::WEAK) |
| 440 .Return(); | 415 .Return(); |
| 441 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 416 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 442 | 417 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 454 | 429 |
| 455 TEST(InterpreterBinaryOpsSmi) { | 430 TEST(InterpreterBinaryOpsSmi) { |
| 456 int lhs_inputs[] = {3266, 1024, 0, -17, -18000}; | 431 int lhs_inputs[] = {3266, 1024, 0, -17, -18000}; |
| 457 int rhs_inputs[] = {3266, 5, 4, 3, 2, 1, -1, -2}; | 432 int rhs_inputs[] = {3266, 5, 4, 3, 2, 1, -1, -2}; |
| 458 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { | 433 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { |
| 459 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { | 434 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { |
| 460 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { | 435 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { |
| 461 HandleAndZoneScope handles; | 436 HandleAndZoneScope handles; |
| 462 i::Factory* factory = handles.main_isolate()->factory(); | 437 i::Factory* factory = handles.main_isolate()->factory(); |
| 463 BytecodeArrayBuilder builder(handles.main_isolate(), | 438 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 464 handles.main_zone()); | 439 handles.main_zone(), 1, 0, 1); |
| 465 builder.set_locals_count(1); | |
| 466 builder.set_context_count(0); | |
| 467 builder.set_parameter_count(1); | |
| 468 Register reg(0); | 440 Register reg(0); |
| 469 int lhs = lhs_inputs[l]; | 441 int lhs = lhs_inputs[l]; |
| 470 int rhs = rhs_inputs[r]; | 442 int rhs = rhs_inputs[r]; |
| 471 builder.LoadLiteral(Smi::FromInt(lhs)) | 443 builder.LoadLiteral(Smi::FromInt(lhs)) |
| 472 .StoreAccumulatorInRegister(reg) | 444 .StoreAccumulatorInRegister(reg) |
| 473 .LoadLiteral(Smi::FromInt(rhs)) | 445 .LoadLiteral(Smi::FromInt(rhs)) |
| 474 .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK) | 446 .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK) |
| 475 .Return(); | 447 .Return(); |
| 476 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 448 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 477 | 449 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 490 TEST(InterpreterBinaryOpsHeapNumber) { | 462 TEST(InterpreterBinaryOpsHeapNumber) { |
| 491 double lhs_inputs[] = {3266.101, 1024.12, 0.01, -17.99, -18000.833, 9.1e17}; | 463 double lhs_inputs[] = {3266.101, 1024.12, 0.01, -17.99, -18000.833, 9.1e17}; |
| 492 double rhs_inputs[] = {3266.101, 5.999, 4.778, 3.331, 2.643, | 464 double rhs_inputs[] = {3266.101, 5.999, 4.778, 3.331, 2.643, |
| 493 1.1, -1.8, -2.9, 8.3e-27}; | 465 1.1, -1.8, -2.9, 8.3e-27}; |
| 494 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { | 466 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { |
| 495 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { | 467 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { |
| 496 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { | 468 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { |
| 497 HandleAndZoneScope handles; | 469 HandleAndZoneScope handles; |
| 498 i::Factory* factory = handles.main_isolate()->factory(); | 470 i::Factory* factory = handles.main_isolate()->factory(); |
| 499 BytecodeArrayBuilder builder(handles.main_isolate(), | 471 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 500 handles.main_zone()); | 472 handles.main_zone(), 1, 0, 1); |
| 501 builder.set_locals_count(1); | |
| 502 builder.set_context_count(0); | |
| 503 builder.set_parameter_count(1); | |
| 504 Register reg(0); | 473 Register reg(0); |
| 505 double lhs = lhs_inputs[l]; | 474 double lhs = lhs_inputs[l]; |
| 506 double rhs = rhs_inputs[r]; | 475 double rhs = rhs_inputs[r]; |
| 507 builder.LoadLiteral(factory->NewNumber(lhs)) | 476 builder.LoadLiteral(factory->NewNumber(lhs)) |
| 508 .StoreAccumulatorInRegister(reg) | 477 .StoreAccumulatorInRegister(reg) |
| 509 .LoadLiteral(factory->NewNumber(rhs)) | 478 .LoadLiteral(factory->NewNumber(rhs)) |
| 510 .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK) | 479 .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK) |
| 511 .Return(); | 480 .Return(); |
| 512 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 481 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 513 | 482 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 factory->NewStringFromStaticChars("a")}, | 518 factory->NewStringFromStaticChars("a")}, |
| 550 {factory->NewStringFromStaticChars("1.11"), factory->NewHeapNumber(2.5), | 519 {factory->NewStringFromStaticChars("1.11"), factory->NewHeapNumber(2.5), |
| 551 factory->NewStringFromStaticChars("1.112.5")}, | 520 factory->NewStringFromStaticChars("1.112.5")}, |
| 552 {factory->NewStringFromStaticChars("-1.11"), factory->NewHeapNumber(2.56), | 521 {factory->NewStringFromStaticChars("-1.11"), factory->NewHeapNumber(2.56), |
| 553 factory->NewStringFromStaticChars("-1.112.56")}, | 522 factory->NewStringFromStaticChars("-1.112.56")}, |
| 554 {factory->NewStringFromStaticChars(""), factory->NewHeapNumber(2.5), | 523 {factory->NewStringFromStaticChars(""), factory->NewHeapNumber(2.5), |
| 555 factory->NewStringFromStaticChars("2.5")}, | 524 factory->NewStringFromStaticChars("2.5")}, |
| 556 }; | 525 }; |
| 557 | 526 |
| 558 for (size_t i = 0; i < arraysize(test_cases); i++) { | 527 for (size_t i = 0; i < arraysize(test_cases); i++) { |
| 559 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 528 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 560 builder.set_locals_count(1); | 529 0, 1); |
| 561 builder.set_context_count(0); | |
| 562 builder.set_parameter_count(1); | |
| 563 Register reg(0); | 530 Register reg(0); |
| 564 builder.LoadLiteral(test_cases[i].lhs) | 531 builder.LoadLiteral(test_cases[i].lhs) |
| 565 .StoreAccumulatorInRegister(reg) | 532 .StoreAccumulatorInRegister(reg) |
| 566 .LoadLiteral(test_cases[i].rhs) | 533 .LoadLiteral(test_cases[i].rhs) |
| 567 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) | 534 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) |
| 568 .Return(); | 535 .Return(); |
| 569 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 536 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 570 | 537 |
| 571 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 538 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 572 auto callable = tester.GetCallable<>(); | 539 auto callable = tester.GetCallable<>(); |
| 573 Handle<Object> return_value = callable().ToHandleChecked(); | 540 Handle<Object> return_value = callable().ToHandleChecked(); |
| 574 CHECK(return_value->SameValue(*test_cases[i].expected_value)); | 541 CHECK(return_value->SameValue(*test_cases[i].expected_value)); |
| 575 } | 542 } |
| 576 } | 543 } |
| 577 | 544 |
| 578 | 545 |
| 579 TEST(InterpreterParameter1) { | 546 TEST(InterpreterParameter1) { |
| 580 HandleAndZoneScope handles; | 547 HandleAndZoneScope handles; |
| 581 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 548 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 582 builder.set_locals_count(0); | 549 0, 0); |
| 583 builder.set_context_count(0); | |
| 584 builder.set_parameter_count(1); | |
| 585 builder.LoadAccumulatorWithRegister(builder.Parameter(0)).Return(); | 550 builder.LoadAccumulatorWithRegister(builder.Parameter(0)).Return(); |
| 586 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 551 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 587 | 552 |
| 588 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 553 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 589 auto callable = tester.GetCallable<Handle<Object>>(); | 554 auto callable = tester.GetCallable<Handle<Object>>(); |
| 590 | 555 |
| 591 // Check for heap objects. | 556 // Check for heap objects. |
| 592 Handle<Object> true_value = handles.main_isolate()->factory()->true_value(); | 557 Handle<Object> true_value = handles.main_isolate()->factory()->true_value(); |
| 593 Handle<Object> return_val = callable(true_value).ToHandleChecked(); | 558 Handle<Object> return_val = callable(true_value).ToHandleChecked(); |
| 594 CHECK(return_val.is_identical_to(true_value)); | 559 CHECK(return_val.is_identical_to(true_value)); |
| 595 | 560 |
| 596 // Check for Smis. | 561 // Check for Smis. |
| 597 return_val = callable(Handle<Smi>(Smi::FromInt(3), handles.main_isolate())) | 562 return_val = callable(Handle<Smi>(Smi::FromInt(3), handles.main_isolate())) |
| 598 .ToHandleChecked(); | 563 .ToHandleChecked(); |
| 599 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(3)); | 564 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(3)); |
| 600 } | 565 } |
| 601 | 566 |
| 602 | 567 |
| 603 TEST(InterpreterParameter8) { | 568 TEST(InterpreterParameter8) { |
| 604 HandleAndZoneScope handles; | 569 HandleAndZoneScope handles; |
| 605 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 570 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 8, |
| 606 builder.set_locals_count(0); | 571 0, 0); |
| 607 builder.set_context_count(0); | |
| 608 builder.set_parameter_count(8); | |
| 609 builder.LoadAccumulatorWithRegister(builder.Parameter(0)) | 572 builder.LoadAccumulatorWithRegister(builder.Parameter(0)) |
| 610 .BinaryOperation(Token::Value::ADD, builder.Parameter(1), Strength::WEAK) | 573 .BinaryOperation(Token::Value::ADD, builder.Parameter(1), Strength::WEAK) |
| 611 .BinaryOperation(Token::Value::ADD, builder.Parameter(2), Strength::WEAK) | 574 .BinaryOperation(Token::Value::ADD, builder.Parameter(2), Strength::WEAK) |
| 612 .BinaryOperation(Token::Value::ADD, builder.Parameter(3), Strength::WEAK) | 575 .BinaryOperation(Token::Value::ADD, builder.Parameter(3), Strength::WEAK) |
| 613 .BinaryOperation(Token::Value::ADD, builder.Parameter(4), Strength::WEAK) | 576 .BinaryOperation(Token::Value::ADD, builder.Parameter(4), Strength::WEAK) |
| 614 .BinaryOperation(Token::Value::ADD, builder.Parameter(5), Strength::WEAK) | 577 .BinaryOperation(Token::Value::ADD, builder.Parameter(5), Strength::WEAK) |
| 615 .BinaryOperation(Token::Value::ADD, builder.Parameter(6), Strength::WEAK) | 578 .BinaryOperation(Token::Value::ADD, builder.Parameter(6), Strength::WEAK) |
| 616 .BinaryOperation(Token::Value::ADD, builder.Parameter(7), Strength::WEAK) | 579 .BinaryOperation(Token::Value::ADD, builder.Parameter(7), Strength::WEAK) |
| 617 .Return(); | 580 .Return(); |
| 618 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 581 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 632 // Check for Smis. | 595 // Check for Smis. |
| 633 Handle<Object> return_val = | 596 Handle<Object> return_val = |
| 634 callable(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) | 597 callable(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) |
| 635 .ToHandleChecked(); | 598 .ToHandleChecked(); |
| 636 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(36)); | 599 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(36)); |
| 637 } | 600 } |
| 638 | 601 |
| 639 | 602 |
| 640 TEST(InterpreterParameter1Assign) { | 603 TEST(InterpreterParameter1Assign) { |
| 641 HandleAndZoneScope handles; | 604 HandleAndZoneScope handles; |
| 642 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 605 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 643 builder.set_locals_count(0); | 606 0, 0); |
| 644 builder.set_context_count(0); | |
| 645 builder.set_parameter_count(1); | |
| 646 builder.LoadLiteral(Smi::FromInt(5)) | 607 builder.LoadLiteral(Smi::FromInt(5)) |
| 647 .StoreAccumulatorInRegister(builder.Parameter(0)) | 608 .StoreAccumulatorInRegister(builder.Parameter(0)) |
| 648 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 609 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
| 649 .Return(); | 610 .Return(); |
| 650 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 611 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 651 | 612 |
| 652 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 613 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 653 auto callable = tester.GetCallable<Handle<Object>>(); | 614 auto callable = tester.GetCallable<Handle<Object>>(); |
| 654 | 615 |
| 655 Handle<Object> return_val = | 616 Handle<Object> return_val = |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 723 |
| 763 i::FeedbackVectorSpec feedback_spec(&zone); | 724 i::FeedbackVectorSpec feedback_spec(&zone); |
| 764 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); | 725 i::FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); |
| 765 | 726 |
| 766 Handle<i::TypeFeedbackVector> vector = | 727 Handle<i::TypeFeedbackVector> vector = |
| 767 i::NewTypeFeedbackVector(isolate, &feedback_spec); | 728 i::NewTypeFeedbackVector(isolate, &feedback_spec); |
| 768 | 729 |
| 769 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 730 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 770 name = factory->string_table()->LookupString(isolate, name); | 731 name = factory->string_table()->LookupString(isolate, name); |
| 771 | 732 |
| 772 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 733 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 773 builder.set_locals_count(0); | 734 0, 0); |
| 774 builder.set_context_count(0); | |
| 775 builder.set_parameter_count(1); | |
| 776 builder.LoadNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot), | 735 builder.LoadNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot), |
| 777 i::SLOPPY) | 736 i::SLOPPY) |
| 778 .Return(); | 737 .Return(); |
| 779 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 738 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 780 | 739 |
| 781 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 740 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 782 auto callable = tester.GetCallable<Handle<Object>>(); | 741 auto callable = tester.GetCallable<Handle<Object>>(); |
| 783 | 742 |
| 784 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); | 743 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); |
| 785 // Test IC miss. | 744 // Test IC miss. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 777 |
| 819 i::FeedbackVectorSpec feedback_spec(&zone); | 778 i::FeedbackVectorSpec feedback_spec(&zone); |
| 820 i::FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); | 779 i::FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); |
| 821 | 780 |
| 822 Handle<i::TypeFeedbackVector> vector = | 781 Handle<i::TypeFeedbackVector> vector = |
| 823 i::NewTypeFeedbackVector(isolate, &feedback_spec); | 782 i::NewTypeFeedbackVector(isolate, &feedback_spec); |
| 824 | 783 |
| 825 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); | 784 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); |
| 826 key = factory->string_table()->LookupString(isolate, key); | 785 key = factory->string_table()->LookupString(isolate, key); |
| 827 | 786 |
| 828 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 787 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 829 builder.set_locals_count(1); | 788 0, 1); |
| 830 builder.set_context_count(0); | |
| 831 builder.set_parameter_count(1); | |
| 832 builder.LoadLiteral(key) | 789 builder.LoadLiteral(key) |
| 833 .LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot), | 790 .LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot), |
| 834 i::STRICT) | 791 i::STRICT) |
| 835 .Return(); | 792 .Return(); |
| 836 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 793 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 837 | 794 |
| 838 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 795 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 839 auto callable = tester.GetCallable<Handle<Object>>(); | 796 auto callable = tester.GetCallable<Handle<Object>>(); |
| 840 | 797 |
| 841 Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })"); | 798 Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 863 | 820 |
| 864 i::FeedbackVectorSpec feedback_spec(&zone); | 821 i::FeedbackVectorSpec feedback_spec(&zone); |
| 865 i::FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot(); | 822 i::FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot(); |
| 866 | 823 |
| 867 Handle<i::TypeFeedbackVector> vector = | 824 Handle<i::TypeFeedbackVector> vector = |
| 868 i::NewTypeFeedbackVector(isolate, &feedback_spec); | 825 i::NewTypeFeedbackVector(isolate, &feedback_spec); |
| 869 | 826 |
| 870 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 827 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 871 name = factory->string_table()->LookupString(isolate, name); | 828 name = factory->string_table()->LookupString(isolate, name); |
| 872 | 829 |
| 873 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 830 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 874 builder.set_locals_count(0); | 831 0, 0); |
| 875 builder.set_context_count(0); | |
| 876 builder.set_parameter_count(1); | |
| 877 builder.LoadLiteral(Smi::FromInt(999)) | 832 builder.LoadLiteral(Smi::FromInt(999)) |
| 878 .StoreNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot), | 833 .StoreNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot), |
| 879 i::STRICT) | 834 i::STRICT) |
| 880 .Return(); | 835 .Return(); |
| 881 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 836 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 882 | 837 |
| 883 InterpreterTester tester(isolate, bytecode_array, vector); | 838 InterpreterTester tester(isolate, bytecode_array, vector); |
| 884 auto callable = tester.GetCallable<Handle<Object>>(); | 839 auto callable = tester.GetCallable<Handle<Object>>(); |
| 885 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); | 840 Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })"); |
| 886 // Test IC miss. | 841 // Test IC miss. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 | 879 |
| 925 i::FeedbackVectorSpec feedback_spec(&zone); | 880 i::FeedbackVectorSpec feedback_spec(&zone); |
| 926 i::FeedbackVectorSlot slot = feedback_spec.AddKeyedStoreICSlot(); | 881 i::FeedbackVectorSlot slot = feedback_spec.AddKeyedStoreICSlot(); |
| 927 | 882 |
| 928 Handle<i::TypeFeedbackVector> vector = | 883 Handle<i::TypeFeedbackVector> vector = |
| 929 i::NewTypeFeedbackVector(isolate, &feedback_spec); | 884 i::NewTypeFeedbackVector(isolate, &feedback_spec); |
| 930 | 885 |
| 931 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 886 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 932 name = factory->string_table()->LookupString(isolate, name); | 887 name = factory->string_table()->LookupString(isolate, name); |
| 933 | 888 |
| 934 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 889 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 935 builder.set_locals_count(1); | 890 0, 1); |
| 936 builder.set_context_count(0); | |
| 937 builder.set_parameter_count(1); | |
| 938 builder.LoadLiteral(name) | 891 builder.LoadLiteral(name) |
| 939 .StoreAccumulatorInRegister(Register(0)) | 892 .StoreAccumulatorInRegister(Register(0)) |
| 940 .LoadLiteral(Smi::FromInt(999)) | 893 .LoadLiteral(Smi::FromInt(999)) |
| 941 .StoreKeyedProperty(builder.Parameter(0), Register(0), | 894 .StoreKeyedProperty(builder.Parameter(0), Register(0), |
| 942 vector->GetIndex(slot), i::SLOPPY) | 895 vector->GetIndex(slot), i::SLOPPY) |
| 943 .Return(); | 896 .Return(); |
| 944 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 897 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 945 | 898 |
| 946 InterpreterTester tester(isolate, bytecode_array, vector); | 899 InterpreterTester tester(isolate, bytecode_array, vector); |
| 947 auto callable = tester.GetCallable<Handle<Object>>(); | 900 auto callable = tester.GetCallable<Handle<Object>>(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 977 | 930 |
| 978 Handle<i::TypeFeedbackVector> vector = | 931 Handle<i::TypeFeedbackVector> vector = |
| 979 i::NewTypeFeedbackVector(isolate, &feedback_spec); | 932 i::NewTypeFeedbackVector(isolate, &feedback_spec); |
| 980 int slot_index = vector->GetIndex(slot); | 933 int slot_index = vector->GetIndex(slot); |
| 981 | 934 |
| 982 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); | 935 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); |
| 983 name = factory->string_table()->LookupString(isolate, name); | 936 name = factory->string_table()->LookupString(isolate, name); |
| 984 | 937 |
| 985 // Check with no args. | 938 // Check with no args. |
| 986 { | 939 { |
| 987 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 940 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 988 builder.set_locals_count(1); | 941 0, 1); |
| 989 builder.set_context_count(0); | |
| 990 builder.set_parameter_count(1); | |
| 991 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) | 942 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) |
| 992 .StoreAccumulatorInRegister(Register(0)) | 943 .StoreAccumulatorInRegister(Register(0)) |
| 993 .Call(Register(0), builder.Parameter(0), 0, 0) | 944 .Call(Register(0), builder.Parameter(0), 0, 0) |
| 994 .Return(); | 945 .Return(); |
| 995 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 946 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 996 | 947 |
| 997 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 948 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 998 auto callable = tester.GetCallable<Handle<Object>>(); | 949 auto callable = tester.GetCallable<Handle<Object>>(); |
| 999 | 950 |
| 1000 Handle<Object> object = InterpreterTester::NewObject( | 951 Handle<Object> object = InterpreterTester::NewObject( |
| 1001 "new (function Obj() { this.func = function() { return 0x265; }})()"); | 952 "new (function Obj() { this.func = function() { return 0x265; }})()"); |
| 1002 Handle<Object> return_val = callable(object).ToHandleChecked(); | 953 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 1003 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); | 954 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); |
| 1004 } | 955 } |
| 1005 | 956 |
| 1006 // Check that receiver is passed properly. | 957 // Check that receiver is passed properly. |
| 1007 { | 958 { |
| 1008 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 959 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 1009 builder.set_locals_count(1); | 960 0, 1); |
| 1010 builder.set_context_count(0); | |
| 1011 builder.set_parameter_count(1); | |
| 1012 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) | 961 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) |
| 1013 .StoreAccumulatorInRegister(Register(0)) | 962 .StoreAccumulatorInRegister(Register(0)) |
| 1014 .Call(Register(0), builder.Parameter(0), 0, 0) | 963 .Call(Register(0), builder.Parameter(0), 0, 0) |
| 1015 .Return(); | 964 .Return(); |
| 1016 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 965 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1017 | 966 |
| 1018 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 967 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 1019 auto callable = tester.GetCallable<Handle<Object>>(); | 968 auto callable = tester.GetCallable<Handle<Object>>(); |
| 1020 | 969 |
| 1021 Handle<Object> object = InterpreterTester::NewObject( | 970 Handle<Object> object = InterpreterTester::NewObject( |
| 1022 "new (function Obj() {" | 971 "new (function Obj() {" |
| 1023 " this.val = 1234;" | 972 " this.val = 1234;" |
| 1024 " this.func = function() { return this.val; };" | 973 " this.func = function() { return this.val; };" |
| 1025 "})()"); | 974 "})()"); |
| 1026 Handle<Object> return_val = callable(object).ToHandleChecked(); | 975 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 1027 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234)); | 976 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(1234)); |
| 1028 } | 977 } |
| 1029 | 978 |
| 1030 // Check with two parameters (+ receiver). | 979 // Check with two parameters (+ receiver). |
| 1031 { | 980 { |
| 1032 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 981 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 1033 builder.set_locals_count(4); | 982 0, 4); |
| 1034 builder.set_context_count(0); | |
| 1035 builder.set_parameter_count(1); | |
| 1036 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) | 983 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) |
| 1037 .StoreAccumulatorInRegister(Register(0)) | 984 .StoreAccumulatorInRegister(Register(0)) |
| 1038 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 985 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
| 1039 .StoreAccumulatorInRegister(Register(1)) | 986 .StoreAccumulatorInRegister(Register(1)) |
| 1040 .LoadLiteral(Smi::FromInt(51)) | 987 .LoadLiteral(Smi::FromInt(51)) |
| 1041 .StoreAccumulatorInRegister(Register(2)) | 988 .StoreAccumulatorInRegister(Register(2)) |
| 1042 .LoadLiteral(Smi::FromInt(11)) | 989 .LoadLiteral(Smi::FromInt(11)) |
| 1043 .StoreAccumulatorInRegister(Register(3)) | 990 .StoreAccumulatorInRegister(Register(3)) |
| 1044 .Call(Register(0), Register(1), 2, 0) | 991 .Call(Register(0), Register(1), 2, 0) |
| 1045 .Return(); | 992 .Return(); |
| 1046 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 993 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1047 | 994 |
| 1048 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); | 995 InterpreterTester tester(handles.main_isolate(), bytecode_array, vector); |
| 1049 auto callable = tester.GetCallable<Handle<Object>>(); | 996 auto callable = tester.GetCallable<Handle<Object>>(); |
| 1050 | 997 |
| 1051 Handle<Object> object = InterpreterTester::NewObject( | 998 Handle<Object> object = InterpreterTester::NewObject( |
| 1052 "new (function Obj() { " | 999 "new (function Obj() { " |
| 1053 " this.func = function(a, b) { return a - b; }" | 1000 " this.func = function(a, b) { return a - b; }" |
| 1054 "})()"); | 1001 "})()"); |
| 1055 Handle<Object> return_val = callable(object).ToHandleChecked(); | 1002 Handle<Object> return_val = callable(object).ToHandleChecked(); |
| 1056 CHECK(return_val->SameValue(Smi::FromInt(40))); | 1003 CHECK(return_val->SameValue(Smi::FromInt(40))); |
| 1057 } | 1004 } |
| 1058 | 1005 |
| 1059 // Check with 10 parameters (+ receiver). | 1006 // Check with 10 parameters (+ receiver). |
| 1060 { | 1007 { |
| 1061 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1008 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 1062 builder.set_locals_count(12); | 1009 0, 12); |
| 1063 builder.set_context_count(0); | |
| 1064 builder.set_parameter_count(1); | |
| 1065 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) | 1010 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index, i::SLOPPY) |
| 1066 .StoreAccumulatorInRegister(Register(0)) | 1011 .StoreAccumulatorInRegister(Register(0)) |
| 1067 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 1012 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
| 1068 .StoreAccumulatorInRegister(Register(1)) | 1013 .StoreAccumulatorInRegister(Register(1)) |
| 1069 .LoadLiteral(factory->NewStringFromAsciiChecked("a")) | 1014 .LoadLiteral(factory->NewStringFromAsciiChecked("a")) |
| 1070 .StoreAccumulatorInRegister(Register(2)) | 1015 .StoreAccumulatorInRegister(Register(2)) |
| 1071 .LoadLiteral(factory->NewStringFromAsciiChecked("b")) | 1016 .LoadLiteral(factory->NewStringFromAsciiChecked("b")) |
| 1072 .StoreAccumulatorInRegister(Register(3)) | 1017 .StoreAccumulatorInRegister(Register(3)) |
| 1073 .LoadLiteral(factory->NewStringFromAsciiChecked("c")) | 1018 .LoadLiteral(factory->NewStringFromAsciiChecked("c")) |
| 1074 .StoreAccumulatorInRegister(Register(4)) | 1019 .StoreAccumulatorInRegister(Register(4)) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 return builder.StoreAccumulatorInRegister(scratch) | 1069 return builder.StoreAccumulatorInRegister(scratch) |
| 1125 .LoadLiteral(Smi::FromInt(value)) | 1070 .LoadLiteral(Smi::FromInt(value)) |
| 1126 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) | 1071 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) |
| 1127 .StoreAccumulatorInRegister(reg) | 1072 .StoreAccumulatorInRegister(reg) |
| 1128 .LoadAccumulatorWithRegister(scratch); | 1073 .LoadAccumulatorWithRegister(scratch); |
| 1129 } | 1074 } |
| 1130 | 1075 |
| 1131 | 1076 |
| 1132 TEST(InterpreterJumps) { | 1077 TEST(InterpreterJumps) { |
| 1133 HandleAndZoneScope handles; | 1078 HandleAndZoneScope handles; |
| 1134 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1079 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1135 builder.set_locals_count(2); | 1080 0, 2); |
| 1136 builder.set_context_count(0); | |
| 1137 builder.set_parameter_count(0); | |
| 1138 Register reg(0), scratch(1); | 1081 Register reg(0), scratch(1); |
| 1139 BytecodeLabel label[3]; | 1082 BytecodeLabel label[3]; |
| 1140 | 1083 |
| 1141 builder.LoadLiteral(Smi::FromInt(0)) | 1084 builder.LoadLiteral(Smi::FromInt(0)) |
| 1142 .StoreAccumulatorInRegister(reg) | 1085 .StoreAccumulatorInRegister(reg) |
| 1143 .Jump(&label[1]); | 1086 .Jump(&label[1]); |
| 1144 SetRegister(builder, reg, 1024, scratch).Bind(&label[0]); | 1087 SetRegister(builder, reg, 1024, scratch).Bind(&label[0]); |
| 1145 IncrementRegister(builder, reg, 1, scratch).Jump(&label[2]); | 1088 IncrementRegister(builder, reg, 1, scratch).Jump(&label[2]); |
| 1146 SetRegister(builder, reg, 2048, scratch).Bind(&label[1]); | 1089 SetRegister(builder, reg, 2048, scratch).Bind(&label[1]); |
| 1147 IncrementRegister(builder, reg, 2, scratch).Jump(&label[0]); | 1090 IncrementRegister(builder, reg, 2, scratch).Jump(&label[0]); |
| 1148 SetRegister(builder, reg, 4096, scratch).Bind(&label[2]); | 1091 SetRegister(builder, reg, 4096, scratch).Bind(&label[2]); |
| 1149 IncrementRegister(builder, reg, 4, scratch) | 1092 IncrementRegister(builder, reg, 4, scratch) |
| 1150 .LoadAccumulatorWithRegister(reg) | 1093 .LoadAccumulatorWithRegister(reg) |
| 1151 .Return(); | 1094 .Return(); |
| 1152 | 1095 |
| 1153 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1096 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1154 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1097 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1155 auto callable = tester.GetCallable<>(); | 1098 auto callable = tester.GetCallable<>(); |
| 1156 Handle<Object> return_value = callable().ToHandleChecked(); | 1099 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1157 CHECK_EQ(Smi::cast(*return_value)->value(), 7); | 1100 CHECK_EQ(Smi::cast(*return_value)->value(), 7); |
| 1158 } | 1101 } |
| 1159 | 1102 |
| 1160 | 1103 |
| 1161 TEST(InterpreterConditionalJumps) { | 1104 TEST(InterpreterConditionalJumps) { |
| 1162 HandleAndZoneScope handles; | 1105 HandleAndZoneScope handles; |
| 1163 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1106 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1164 builder.set_locals_count(2); | 1107 0, 2); |
| 1165 builder.set_context_count(0); | |
| 1166 builder.set_parameter_count(0); | |
| 1167 Register reg(0), scratch(1); | 1108 Register reg(0), scratch(1); |
| 1168 BytecodeLabel label[2]; | 1109 BytecodeLabel label[2]; |
| 1169 BytecodeLabel done, done1; | 1110 BytecodeLabel done, done1; |
| 1170 | 1111 |
| 1171 builder.LoadLiteral(Smi::FromInt(0)) | 1112 builder.LoadLiteral(Smi::FromInt(0)) |
| 1172 .StoreAccumulatorInRegister(reg) | 1113 .StoreAccumulatorInRegister(reg) |
| 1173 .LoadFalse() | 1114 .LoadFalse() |
| 1174 .JumpIfFalse(&label[0]); | 1115 .JumpIfFalse(&label[0]); |
| 1175 IncrementRegister(builder, reg, 1024, scratch) | 1116 IncrementRegister(builder, reg, 1024, scratch) |
| 1176 .Bind(&label[0]) | 1117 .Bind(&label[0]) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1189 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1130 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1190 auto callable = tester.GetCallable<>(); | 1131 auto callable = tester.GetCallable<>(); |
| 1191 Handle<Object> return_value = callable().ToHandleChecked(); | 1132 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1192 CHECK_EQ(Smi::cast(*return_value)->value(), 7); | 1133 CHECK_EQ(Smi::cast(*return_value)->value(), 7); |
| 1193 } | 1134 } |
| 1194 | 1135 |
| 1195 | 1136 |
| 1196 TEST(InterpreterConditionalJumps2) { | 1137 TEST(InterpreterConditionalJumps2) { |
| 1197 // TODO(oth): Add tests for all conditional jumps near and far. | 1138 // TODO(oth): Add tests for all conditional jumps near and far. |
| 1198 HandleAndZoneScope handles; | 1139 HandleAndZoneScope handles; |
| 1199 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1140 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1200 builder.set_locals_count(2); | 1141 0, 2); |
| 1201 builder.set_context_count(0); | |
| 1202 builder.set_parameter_count(0); | |
| 1203 Register reg(0), scratch(1); | 1142 Register reg(0), scratch(1); |
| 1204 BytecodeLabel label[2]; | 1143 BytecodeLabel label[2]; |
| 1205 BytecodeLabel done, done1; | 1144 BytecodeLabel done, done1; |
| 1206 | 1145 |
| 1207 builder.LoadLiteral(Smi::FromInt(0)) | 1146 builder.LoadLiteral(Smi::FromInt(0)) |
| 1208 .StoreAccumulatorInRegister(reg) | 1147 .StoreAccumulatorInRegister(reg) |
| 1209 .LoadFalse() | 1148 .LoadFalse() |
| 1210 .JumpIfFalse(&label[0]); | 1149 .JumpIfFalse(&label[0]); |
| 1211 IncrementRegister(builder, reg, 1024, scratch) | 1150 IncrementRegister(builder, reg, 1024, scratch) |
| 1212 .Bind(&label[0]) | 1151 .Bind(&label[0]) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 12345678, | 1216 12345678, |
| 1278 v8::internal::kMaxInt / 4, | 1217 v8::internal::kMaxInt / 4, |
| 1279 v8::internal::kMaxInt / 2}; | 1218 v8::internal::kMaxInt / 2}; |
| 1280 | 1219 |
| 1281 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { | 1220 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { |
| 1282 Token::Value comparison = kComparisonTypes[c]; | 1221 Token::Value comparison = kComparisonTypes[c]; |
| 1283 for (size_t i = 0; i < arraysize(inputs); i++) { | 1222 for (size_t i = 0; i < arraysize(inputs); i++) { |
| 1284 for (size_t j = 0; j < arraysize(inputs); j++) { | 1223 for (size_t j = 0; j < arraysize(inputs); j++) { |
| 1285 HandleAndZoneScope handles; | 1224 HandleAndZoneScope handles; |
| 1286 BytecodeArrayBuilder builder(handles.main_isolate(), | 1225 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 1287 handles.main_zone()); | 1226 handles.main_zone(), 0, 0, 1); |
| 1288 Register r0(0); | 1227 Register r0(0); |
| 1289 builder.set_locals_count(1); | |
| 1290 builder.set_context_count(0); | |
| 1291 builder.set_parameter_count(0); | |
| 1292 builder.LoadLiteral(Smi::FromInt(inputs[i])) | 1228 builder.LoadLiteral(Smi::FromInt(inputs[i])) |
| 1293 .StoreAccumulatorInRegister(r0) | 1229 .StoreAccumulatorInRegister(r0) |
| 1294 .LoadLiteral(Smi::FromInt(inputs[j])) | 1230 .LoadLiteral(Smi::FromInt(inputs[j])) |
| 1295 .CompareOperation(comparison, r0, Strength::WEAK) | 1231 .CompareOperation(comparison, r0, Strength::WEAK) |
| 1296 .Return(); | 1232 .Return(); |
| 1297 | 1233 |
| 1298 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1234 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1299 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1235 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1300 auto callable = tester.GetCallable<>(); | 1236 auto callable = tester.GetCallable<>(); |
| 1301 Handle<Object> return_value = callable().ToHandleChecked(); | 1237 Handle<Object> return_value = callable().ToHandleChecked(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1316 0.1000001, | 1252 0.1000001, |
| 1317 1e99, | 1253 1e99, |
| 1318 -1e-99}; | 1254 -1e-99}; |
| 1319 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { | 1255 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { |
| 1320 Token::Value comparison = kComparisonTypes[c]; | 1256 Token::Value comparison = kComparisonTypes[c]; |
| 1321 for (size_t i = 0; i < arraysize(inputs); i++) { | 1257 for (size_t i = 0; i < arraysize(inputs); i++) { |
| 1322 for (size_t j = 0; j < arraysize(inputs); j++) { | 1258 for (size_t j = 0; j < arraysize(inputs); j++) { |
| 1323 HandleAndZoneScope handles; | 1259 HandleAndZoneScope handles; |
| 1324 i::Factory* factory = handles.main_isolate()->factory(); | 1260 i::Factory* factory = handles.main_isolate()->factory(); |
| 1325 BytecodeArrayBuilder builder(handles.main_isolate(), | 1261 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 1326 handles.main_zone()); | 1262 handles.main_zone(), 0, 0, 1); |
| 1327 Register r0(0); | 1263 Register r0(0); |
| 1328 builder.set_locals_count(1); | |
| 1329 builder.set_context_count(0); | |
| 1330 builder.set_parameter_count(0); | |
| 1331 builder.LoadLiteral(factory->NewHeapNumber(inputs[i])) | 1264 builder.LoadLiteral(factory->NewHeapNumber(inputs[i])) |
| 1332 .StoreAccumulatorInRegister(r0) | 1265 .StoreAccumulatorInRegister(r0) |
| 1333 .LoadLiteral(factory->NewHeapNumber(inputs[j])) | 1266 .LoadLiteral(factory->NewHeapNumber(inputs[j])) |
| 1334 .CompareOperation(comparison, r0, Strength::WEAK) | 1267 .CompareOperation(comparison, r0, Strength::WEAK) |
| 1335 .Return(); | 1268 .Return(); |
| 1336 | 1269 |
| 1337 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1270 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1338 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1271 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1339 auto callable = tester.GetCallable<>(); | 1272 auto callable = tester.GetCallable<>(); |
| 1340 Handle<Object> return_value = callable().ToHandleChecked(); | 1273 Handle<Object> return_value = callable().ToHandleChecked(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1352 | 1285 |
| 1353 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { | 1286 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { |
| 1354 Token::Value comparison = kComparisonTypes[c]; | 1287 Token::Value comparison = kComparisonTypes[c]; |
| 1355 for (size_t i = 0; i < arraysize(inputs); i++) { | 1288 for (size_t i = 0; i < arraysize(inputs); i++) { |
| 1356 for (size_t j = 0; j < arraysize(inputs); j++) { | 1289 for (size_t j = 0; j < arraysize(inputs); j++) { |
| 1357 const char* lhs = inputs[i].c_str(); | 1290 const char* lhs = inputs[i].c_str(); |
| 1358 const char* rhs = inputs[j].c_str(); | 1291 const char* rhs = inputs[j].c_str(); |
| 1359 HandleAndZoneScope handles; | 1292 HandleAndZoneScope handles; |
| 1360 i::Factory* factory = handles.main_isolate()->factory(); | 1293 i::Factory* factory = handles.main_isolate()->factory(); |
| 1361 BytecodeArrayBuilder builder(handles.main_isolate(), | 1294 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 1362 handles.main_zone()); | 1295 handles.main_zone(), 0, 0, 1); |
| 1363 Register r0(0); | 1296 Register r0(0); |
| 1364 builder.set_locals_count(1); | |
| 1365 builder.set_context_count(0); | |
| 1366 builder.set_parameter_count(0); | |
| 1367 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) | 1297 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) |
| 1368 .StoreAccumulatorInRegister(r0) | 1298 .StoreAccumulatorInRegister(r0) |
| 1369 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) | 1299 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) |
| 1370 .CompareOperation(comparison, r0, Strength::WEAK) | 1300 .CompareOperation(comparison, r0, Strength::WEAK) |
| 1371 .Return(); | 1301 .Return(); |
| 1372 | 1302 |
| 1373 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1303 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1374 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1304 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1375 auto callable = tester.GetCallable<>(); | 1305 auto callable = tester.GetCallable<>(); |
| 1376 Handle<Object> return_value = callable().ToHandleChecked(); | 1306 Handle<Object> return_value = callable().ToHandleChecked(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1399 for (int pass = 0; pass < 2; pass++) { | 1329 for (int pass = 0; pass < 2; pass++) { |
| 1400 const char* lhs_cstr = inputs[i]; | 1330 const char* lhs_cstr = inputs[i]; |
| 1401 const char* rhs_cstr = inputs[j]; | 1331 const char* rhs_cstr = inputs[j]; |
| 1402 double lhs = StringToDouble(&unicode_cache, lhs_cstr, | 1332 double lhs = StringToDouble(&unicode_cache, lhs_cstr, |
| 1403 i::ConversionFlags::NO_FLAGS); | 1333 i::ConversionFlags::NO_FLAGS); |
| 1404 double rhs = StringToDouble(&unicode_cache, rhs_cstr, | 1334 double rhs = StringToDouble(&unicode_cache, rhs_cstr, |
| 1405 i::ConversionFlags::NO_FLAGS); | 1335 i::ConversionFlags::NO_FLAGS); |
| 1406 HandleAndZoneScope handles; | 1336 HandleAndZoneScope handles; |
| 1407 i::Factory* factory = handles.main_isolate()->factory(); | 1337 i::Factory* factory = handles.main_isolate()->factory(); |
| 1408 BytecodeArrayBuilder builder(handles.main_isolate(), | 1338 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 1409 handles.main_zone()); | 1339 handles.main_zone(), 0, 0, 1); |
| 1410 Register r0(0); | 1340 Register r0(0); |
| 1411 builder.set_locals_count(1); | |
| 1412 builder.set_context_count(0); | |
| 1413 builder.set_parameter_count(0); | |
| 1414 if (pass == 0) { | 1341 if (pass == 0) { |
| 1415 // Comparison with HeapNumber on the lhs and String on the rhs | 1342 // Comparison with HeapNumber on the lhs and String on the rhs |
| 1416 builder.LoadLiteral(factory->NewNumber(lhs)) | 1343 builder.LoadLiteral(factory->NewNumber(lhs)) |
| 1417 .StoreAccumulatorInRegister(r0) | 1344 .StoreAccumulatorInRegister(r0) |
| 1418 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr)) | 1345 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr)) |
| 1419 .CompareOperation(comparison, r0, Strength::WEAK) | 1346 .CompareOperation(comparison, r0, Strength::WEAK) |
| 1420 .Return(); | 1347 .Return(); |
| 1421 } else { | 1348 } else { |
| 1422 // Comparison with HeapNumber on the rhs and String on the lhs | 1349 // Comparison with HeapNumber on the rhs and String on the lhs |
| 1423 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr)) | 1350 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr)) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1444 TEST(InterpreterInstanceOf) { | 1371 TEST(InterpreterInstanceOf) { |
| 1445 HandleAndZoneScope handles; | 1372 HandleAndZoneScope handles; |
| 1446 i::Factory* factory = handles.main_isolate()->factory(); | 1373 i::Factory* factory = handles.main_isolate()->factory(); |
| 1447 Handle<i::String> name = factory->NewStringFromAsciiChecked("cons"); | 1374 Handle<i::String> name = factory->NewStringFromAsciiChecked("cons"); |
| 1448 Handle<i::JSFunction> func = factory->NewFunction(name); | 1375 Handle<i::JSFunction> func = factory->NewFunction(name); |
| 1449 Handle<i::JSObject> instance = factory->NewJSObject(func); | 1376 Handle<i::JSObject> instance = factory->NewJSObject(func); |
| 1450 Handle<i::Object> other = factory->NewNumber(3.3333); | 1377 Handle<i::Object> other = factory->NewNumber(3.3333); |
| 1451 Handle<i::Object> cases[] = {Handle<i::Object>::cast(instance), other}; | 1378 Handle<i::Object> cases[] = {Handle<i::Object>::cast(instance), other}; |
| 1452 for (size_t i = 0; i < arraysize(cases); i++) { | 1379 for (size_t i = 0; i < arraysize(cases); i++) { |
| 1453 bool expected_value = (i == 0); | 1380 bool expected_value = (i == 0); |
| 1454 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1381 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1382 0, 1); |
| 1455 Register r0(0); | 1383 Register r0(0); |
| 1456 builder.set_locals_count(1); | |
| 1457 builder.set_context_count(0); | |
| 1458 builder.set_parameter_count(0); | |
| 1459 builder.LoadLiteral(cases[i]); | 1384 builder.LoadLiteral(cases[i]); |
| 1460 builder.StoreAccumulatorInRegister(r0) | 1385 builder.StoreAccumulatorInRegister(r0) |
| 1461 .LoadLiteral(func) | 1386 .LoadLiteral(func) |
| 1462 .CompareOperation(Token::Value::INSTANCEOF, r0, Strength::WEAK) | 1387 .CompareOperation(Token::Value::INSTANCEOF, r0, Strength::WEAK) |
| 1463 .Return(); | 1388 .Return(); |
| 1464 | 1389 |
| 1465 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1390 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1466 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1391 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1467 auto callable = tester.GetCallable<>(); | 1392 auto callable = tester.GetCallable<>(); |
| 1468 Handle<Object> return_value = callable().ToHandleChecked(); | 1393 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1469 CHECK(return_value->IsBoolean()); | 1394 CHECK(return_value->IsBoolean()); |
| 1470 CHECK_EQ(return_value->BooleanValue(), expected_value); | 1395 CHECK_EQ(return_value->BooleanValue(), expected_value); |
| 1471 } | 1396 } |
| 1472 } | 1397 } |
| 1473 | 1398 |
| 1474 | 1399 |
| 1475 TEST(InterpreterTestIn) { | 1400 TEST(InterpreterTestIn) { |
| 1476 HandleAndZoneScope handles; | 1401 HandleAndZoneScope handles; |
| 1477 i::Factory* factory = handles.main_isolate()->factory(); | 1402 i::Factory* factory = handles.main_isolate()->factory(); |
| 1478 // Allocate an array | 1403 // Allocate an array |
| 1479 Handle<i::JSArray> array = | 1404 Handle<i::JSArray> array = |
| 1480 factory->NewJSArray(0, i::ElementsKind::FAST_SMI_ELEMENTS); | 1405 factory->NewJSArray(0, i::ElementsKind::FAST_SMI_ELEMENTS); |
| 1481 // Check for these properties on the array object | 1406 // Check for these properties on the array object |
| 1482 const char* properties[] = {"length", "fuzzle", "x", "0"}; | 1407 const char* properties[] = {"length", "fuzzle", "x", "0"}; |
| 1483 for (size_t i = 0; i < arraysize(properties); i++) { | 1408 for (size_t i = 0; i < arraysize(properties); i++) { |
| 1484 bool expected_value = (i == 0); | 1409 bool expected_value = (i == 0); |
| 1485 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1410 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1411 0, 1); |
| 1486 Register r0(0); | 1412 Register r0(0); |
| 1487 builder.set_locals_count(1); | |
| 1488 builder.set_context_count(0); | |
| 1489 builder.set_parameter_count(0); | |
| 1490 builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i])) | 1413 builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i])) |
| 1491 .StoreAccumulatorInRegister(r0) | 1414 .StoreAccumulatorInRegister(r0) |
| 1492 .LoadLiteral(Handle<Object>::cast(array)) | 1415 .LoadLiteral(Handle<Object>::cast(array)) |
| 1493 .CompareOperation(Token::Value::IN, r0, Strength::WEAK) | 1416 .CompareOperation(Token::Value::IN, r0, Strength::WEAK) |
| 1494 .Return(); | 1417 .Return(); |
| 1495 | 1418 |
| 1496 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1419 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1497 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1420 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1498 auto callable = tester.GetCallable<>(); | 1421 auto callable = tester.GetCallable<>(); |
| 1499 Handle<Object> return_value = callable().ToHandleChecked(); | 1422 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1500 CHECK(return_value->IsBoolean()); | 1423 CHECK(return_value->IsBoolean()); |
| 1501 CHECK_EQ(return_value->BooleanValue(), expected_value); | 1424 CHECK_EQ(return_value->BooleanValue(), expected_value); |
| 1502 } | 1425 } |
| 1503 } | 1426 } |
| 1504 | 1427 |
| 1505 | 1428 |
| 1506 TEST(InterpreterUnaryNot) { | 1429 TEST(InterpreterUnaryNot) { |
| 1507 HandleAndZoneScope handles; | 1430 HandleAndZoneScope handles; |
| 1508 for (size_t i = 1; i < 10; i++) { | 1431 for (size_t i = 1; i < 10; i++) { |
| 1509 bool expected_value = ((i & 1) == 1); | 1432 bool expected_value = ((i & 1) == 1); |
| 1510 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1433 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1434 0, 0); |
| 1511 Register r0(0); | 1435 Register r0(0); |
| 1512 builder.set_locals_count(0); | |
| 1513 builder.set_context_count(0); | |
| 1514 builder.set_parameter_count(0); | |
| 1515 builder.LoadFalse(); | 1436 builder.LoadFalse(); |
| 1516 for (size_t j = 0; j < i; j++) { | 1437 for (size_t j = 0; j < i; j++) { |
| 1517 builder.LogicalNot(); | 1438 builder.LogicalNot(); |
| 1518 } | 1439 } |
| 1519 builder.Return(); | 1440 builder.Return(); |
| 1520 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1441 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1521 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1442 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1522 auto callable = tester.GetCallable<>(); | 1443 auto callable = tester.GetCallable<>(); |
| 1523 Handle<Object> return_value = callable().ToHandleChecked(); | 1444 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1524 CHECK(return_value->IsBoolean()); | 1445 CHECK(return_value->IsBoolean()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 std::make_pair(factory->NewNumber(9.1), false), | 1484 std::make_pair(factory->NewNumber(9.1), false), |
| 1564 std::make_pair(factory->NewNumberFromInt(0), true), | 1485 std::make_pair(factory->NewNumberFromInt(0), true), |
| 1565 std::make_pair( | 1486 std::make_pair( |
| 1566 Handle<Object>::cast(factory->NewStringFromStaticChars("hello")), | 1487 Handle<Object>::cast(factory->NewStringFromStaticChars("hello")), |
| 1567 false), | 1488 false), |
| 1568 std::make_pair( | 1489 std::make_pair( |
| 1569 Handle<Object>::cast(factory->NewStringFromStaticChars("")), true), | 1490 Handle<Object>::cast(factory->NewStringFromStaticChars("")), true), |
| 1570 }; | 1491 }; |
| 1571 | 1492 |
| 1572 for (size_t i = 0; i < arraysize(object_type_tuples); i++) { | 1493 for (size_t i = 0; i < arraysize(object_type_tuples); i++) { |
| 1573 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1494 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, |
| 1495 0, 0); |
| 1574 Register r0(0); | 1496 Register r0(0); |
| 1575 builder.set_locals_count(0); | |
| 1576 builder.set_context_count(0); | |
| 1577 builder.set_parameter_count(0); | |
| 1578 LoadAny(&builder, factory, object_type_tuples[i].first); | 1497 LoadAny(&builder, factory, object_type_tuples[i].first); |
| 1579 builder.LogicalNot(); | 1498 builder.LogicalNot(); |
| 1580 builder.Return(); | 1499 builder.Return(); |
| 1581 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1500 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1582 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1501 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1583 auto callable = tester.GetCallable<>(); | 1502 auto callable = tester.GetCallable<>(); |
| 1584 Handle<Object> return_value = callable().ToHandleChecked(); | 1503 Handle<Object> return_value = callable().ToHandleChecked(); |
| 1585 CHECK(return_value->IsBoolean()); | 1504 CHECK(return_value->IsBoolean()); |
| 1586 CHECK_EQ(return_value->BooleanValue(), object_type_tuples[i].second); | 1505 CHECK_EQ(return_value->BooleanValue(), object_type_tuples[i].second); |
| 1587 } | 1506 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1611 Handle<v8::internal::String>::cast(callable().ToHandleChecked()); | 1530 Handle<v8::internal::String>::cast(callable().ToHandleChecked()); |
| 1612 auto actual = return_value->ToCString(); | 1531 auto actual = return_value->ToCString(); |
| 1613 CHECK_EQ(strcmp(&actual[0], typeof_vals[i].second), 0); | 1532 CHECK_EQ(strcmp(&actual[0], typeof_vals[i].second), 0); |
| 1614 } | 1533 } |
| 1615 } | 1534 } |
| 1616 | 1535 |
| 1617 | 1536 |
| 1618 TEST(InterpreterCallRuntime) { | 1537 TEST(InterpreterCallRuntime) { |
| 1619 HandleAndZoneScope handles; | 1538 HandleAndZoneScope handles; |
| 1620 | 1539 |
| 1621 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 1540 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, |
| 1622 builder.set_locals_count(2); | 1541 0, 2); |
| 1623 builder.set_context_count(0); | |
| 1624 builder.set_parameter_count(1); | |
| 1625 builder.LoadLiteral(Smi::FromInt(15)) | 1542 builder.LoadLiteral(Smi::FromInt(15)) |
| 1626 .StoreAccumulatorInRegister(Register(0)) | 1543 .StoreAccumulatorInRegister(Register(0)) |
| 1627 .LoadLiteral(Smi::FromInt(40)) | 1544 .LoadLiteral(Smi::FromInt(40)) |
| 1628 .StoreAccumulatorInRegister(Register(1)) | 1545 .StoreAccumulatorInRegister(Register(1)) |
| 1629 .CallRuntime(Runtime::kAdd, Register(0), 2) | 1546 .CallRuntime(Runtime::kAdd, Register(0), 2) |
| 1630 .Return(); | 1547 .Return(); |
| 1631 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1548 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1632 | 1549 |
| 1633 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1550 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1634 auto callable = tester.GetCallable<>(); | 1551 auto callable = tester.GetCallable<>(); |
| (...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3438 auto callable = tester.GetCallable<>(); | 3355 auto callable = tester.GetCallable<>(); |
| 3439 | 3356 |
| 3440 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3357 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3441 CHECK(return_value->SameValue(*delete_lookup_slot[i].second)); | 3358 CHECK(return_value->SameValue(*delete_lookup_slot[i].second)); |
| 3442 } | 3359 } |
| 3443 } | 3360 } |
| 3444 | 3361 |
| 3445 | 3362 |
| 3446 TEST(JumpWithConstantsAndWideConstants) { | 3363 TEST(JumpWithConstantsAndWideConstants) { |
| 3447 HandleAndZoneScope handles; | 3364 HandleAndZoneScope handles; |
| 3448 auto isolate = handles.main_isolate(); | |
| 3449 auto factory = isolate->factory(); | |
| 3450 const int kStep = 13; | 3365 const int kStep = 13; |
| 3451 for (int constants = 3; constants < 256 + 3 * kStep; constants += kStep) { | 3366 for (int constants = 11; constants < 256 + 3 * kStep; constants += kStep) { |
| 3367 auto isolate = handles.main_isolate(); |
| 3368 auto factory = isolate->factory(); |
| 3452 std::ostringstream filler_os; | 3369 std::ostringstream filler_os; |
| 3453 // Generate a string that consumes constant pool entries and | 3370 // Generate a string that consumes constant pool entries and |
| 3454 // spread out branch distances in script below. | 3371 // spread out branch distances in script below. |
| 3455 for (int i = 0; i < constants; i++) { | 3372 for (int i = 0; i < constants; i++) { |
| 3456 filler_os << "var x_ = 'x_" << i << "';\n"; | 3373 filler_os << "var x_ = 'x_" << i << "';\n"; |
| 3457 } | 3374 } |
| 3458 std::string filler(filler_os.str()); | 3375 std::string filler(filler_os.str()); |
| 3459 std::ostringstream script_os; | 3376 std::ostringstream script_os; |
| 3460 script_os << "function " << InterpreterTester::function_name() << "(a) {\n"; | 3377 script_os << "function " << InterpreterTester::function_name() << "(a) {\n"; |
| 3461 script_os << " " << filler; | 3378 script_os << " " << filler; |
| 3462 script_os << " for (var i = a; i < 2; i++) {\n"; | 3379 script_os << " for (var i = a; i < 2; i++) {\n"; |
| 3463 script_os << " " << filler; | 3380 script_os << " " << filler; |
| 3464 script_os << " if (i == 0) { " << filler << "i = 10; continue; }\n"; | 3381 script_os << " if (i == 0) { " << filler << "i = 10; continue; }\n"; |
| 3465 script_os << " else if (i == a) { " << filler << "i = 12; break; }\n"; | 3382 script_os << " else if (i == a) { " << filler << "i = 12; break; }\n"; |
| 3466 script_os << " else { " << filler << " }\n"; | 3383 script_os << " else { " << filler << " }\n"; |
| 3467 script_os << " }\n"; | 3384 script_os << " }\n"; |
| 3468 script_os << " return i;\n"; | 3385 script_os << " return i;\n"; |
| 3469 script_os << "}\n"; | 3386 script_os << "}\n"; |
| 3470 std::string script(script_os.str()); | 3387 std::string script(script_os.str()); |
| 3471 for (int a = 0; a < 3; a++) { | 3388 for (int a = 0; a < 3; a++) { |
| 3472 InterpreterTester tester(handles.main_isolate(), script.c_str()); | 3389 InterpreterTester tester(handles.main_isolate(), script.c_str()); |
| 3473 auto callable = tester.GetCallable<Handle<Object>>(); | 3390 auto callable = tester.GetCallable<Handle<Object>>(); |
| 3474 Handle<Object> return_val = | 3391 Handle<Object> argument = factory->NewNumberFromInt(a); |
| 3475 callable(factory->NewNumberFromInt(a)).ToHandleChecked(); | 3392 Handle<Object> return_val = callable(argument).ToHandleChecked(); |
| 3476 static const int results[] = {11, 12, 2}; | 3393 static const int results[] = {11, 12, 2}; |
| 3477 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]); | 3394 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]); |
| 3478 } | 3395 } |
| 3479 } | 3396 } |
| 3480 } | 3397 } |
| 3481 | 3398 |
| 3482 | 3399 |
| 3483 TEST(InterpreterEval) { | 3400 TEST(InterpreterEval) { |
| 3484 HandleAndZoneScope handles; | 3401 HandleAndZoneScope handles; |
| 3485 i::Isolate* isolate = handles.main_isolate(); | 3402 i::Isolate* isolate = handles.main_isolate(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3516 {"var x = {}; eval('var x = 10;'); return typeof x;", | 3433 {"var x = {}; eval('var x = 10;'); return typeof x;", |
| 3517 factory->NewStringFromStaticChars("number")}, | 3434 factory->NewStringFromStaticChars("number")}, |
| 3518 {"'use strict'; var x = {}; eval('var x = 10;'); return typeof x;", | 3435 {"'use strict'; var x = {}; eval('var x = 10;'); return typeof x;", |
| 3519 factory->NewStringFromStaticChars("object")}, | 3436 factory->NewStringFromStaticChars("object")}, |
| 3520 }; | 3437 }; |
| 3521 | 3438 |
| 3522 for (size_t i = 0; i < arraysize(eval); i++) { | 3439 for (size_t i = 0; i < arraysize(eval); i++) { |
| 3523 std::string source(InterpreterTester::SourceForBody(eval[i].first)); | 3440 std::string source(InterpreterTester::SourceForBody(eval[i].first)); |
| 3524 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 3441 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
| 3525 auto callable = tester.GetCallable<>(); | 3442 auto callable = tester.GetCallable<>(); |
| 3526 | |
| 3527 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3443 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3528 CHECK(return_value->SameValue(*eval[i].second)); | 3444 CHECK(return_value->SameValue(*eval[i].second)); |
| 3529 } | 3445 } |
| 3530 } | 3446 } |
| 3531 | 3447 |
| 3532 | 3448 |
| 3533 TEST(InterpreterEvalParams) { | 3449 TEST(InterpreterEvalParams) { |
| 3534 HandleAndZoneScope handles; | 3450 HandleAndZoneScope handles; |
| 3535 i::Isolate* isolate = handles.main_isolate(); | 3451 i::Isolate* isolate = handles.main_isolate(); |
| 3536 | 3452 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3830 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3746 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3831 CHECK(return_value->SameValue(*do_expr[i].second)); | 3747 CHECK(return_value->SameValue(*do_expr[i].second)); |
| 3832 } | 3748 } |
| 3833 | 3749 |
| 3834 FLAG_harmony_do_expressions = old_flag; | 3750 FLAG_harmony_do_expressions = old_flag; |
| 3835 } | 3751 } |
| 3836 | 3752 |
| 3837 } // namespace interpreter | 3753 } // namespace interpreter |
| 3838 } // namespace internal | 3754 } // namespace internal |
| 3839 } // namespace v8 | 3755 } // namespace v8 |
| OLD | NEW |