| 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/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 6215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6226 } | 6226 } |
| 6227 } | 6227 } |
| 6228 | 6228 |
| 6229 | 6229 |
| 6230 TEST(Eval) { | 6230 TEST(Eval) { |
| 6231 InitializedHandleScope handle_scope; | 6231 InitializedHandleScope handle_scope; |
| 6232 BytecodeGeneratorHelper helper; | 6232 BytecodeGeneratorHelper helper; |
| 6233 Zone zone; | 6233 Zone zone; |
| 6234 | 6234 |
| 6235 int closure = Register::function_closure().index(); | 6235 int closure = Register::function_closure().index(); |
| 6236 int context = Register::function_context().index(); | |
| 6237 int new_target = Register::new_target().index(); | 6236 int new_target = Register::new_target().index(); |
| 6238 | 6237 |
| 6239 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 6238 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 6240 | 6239 |
| 6241 ExpectedSnippet<const char*> snippets[] = { | 6240 ExpectedSnippet<const char*> snippets[] = { |
| 6242 {"return eval('1;');", | 6241 {"return eval('1;');", |
| 6243 9 * kPointerSize, | 6242 9 * kPointerSize, |
| 6244 1, | 6243 1, |
| 6245 67, | 6244 67, |
| 6246 { | 6245 { |
| 6247 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6246 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6248 U8(1), // | 6247 U8(1), // |
| 6249 B(PushContext), R(0), // | 6248 B(PushContext), R(0), // |
| 6250 B(Ldar), THIS(1), // | 6249 B(Ldar), THIS(1), // |
| 6251 B(StaContextSlot), R(0), U8(first_context_slot), // | 6250 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 6252 B(CreateMappedArguments), // | 6251 B(CreateMappedArguments), // |
| 6253 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6252 B(StaContextSlot), R(0), U8(first_context_slot + 1), // |
| 6254 B(Ldar), R(new_target), // | 6253 B(Ldar), R(new_target), // |
| 6255 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6254 B(StaContextSlot), R(0), U8(first_context_slot + 2), // |
| 6256 B(Mov), R(context), R(3), // | 6255 B(Mov), R(0), R(3), // |
| 6257 B(LdaConstant), U8(0), // | 6256 B(LdaConstant), U8(0), // |
| 6258 B(Star), R(4), // | 6257 B(Star), R(4), // |
| 6259 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6258 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6260 R(3), U8(2), R(1), // | 6259 R(3), U8(2), R(1), // |
| 6261 B(LdaConstant), U8(1), // | 6260 B(LdaConstant), U8(1), // |
| 6262 B(Star), R(3), // | 6261 B(Star), R(3), // |
| 6263 B(Mov), R(1), R(4), // | 6262 B(Mov), R(1), R(4), // |
| 6264 B(Mov), R(3), R(5), // | 6263 B(Mov), R(3), R(5), // |
| 6265 B(Mov), R(closure), R(6), // | 6264 B(Mov), R(closure), R(6), // |
| 6266 B(LdaZero), // | 6265 B(LdaZero), // |
| 6267 B(Star), R(7), // | 6266 B(Star), R(7), // |
| 6268 B(LdaSmi8), U8(10), // | 6267 B(LdaSmi8), U8(10), // |
| 6269 B(Star), R(8), // | 6268 B(Star), R(8), // |
| 6270 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 6269 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
| 6271 U8(5), // | 6270 U8(5), // |
| 6272 B(Star), R(1), // | 6271 B(Star), R(1), // |
| 6273 B(Call), R(1), R(2), U8(1), U8(0), // | 6272 B(Call), R(1), R(2), U8(1), U8(0), // |
| 6274 B(Return), // | 6273 B(Return), // |
| 6275 }, | 6274 }, |
| 6276 2, | 6275 2, |
| 6277 {"eval", "1;"}}, | 6276 {"eval", "1;"}}, |
| 6278 }; | 6277 }; |
| 6279 | 6278 |
| 6280 for (size_t i = 0; i < arraysize(snippets); i++) { | 6279 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 6281 Handle<BytecodeArray> bytecode_array = | 6280 Handle<BytecodeArray> bytecode_array = |
| 6282 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 6281 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 6283 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6282 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6284 } | 6283 } |
| 6285 } | 6284 } |
| 6286 | 6285 |
| 6287 | 6286 |
| 6288 TEST(LookupSlot) { | 6287 TEST(LookupSlot) { |
| 6289 InitializedHandleScope handle_scope; | 6288 InitializedHandleScope handle_scope; |
| 6290 BytecodeGeneratorHelper helper; | 6289 BytecodeGeneratorHelper helper; |
| 6291 | 6290 |
| 6292 int closure = Register::function_closure().index(); | 6291 int closure = Register::function_closure().index(); |
| 6293 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 6292 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 6294 int context = Register::function_context().index(); | |
| 6295 int new_target = Register::new_target().index(); | 6293 int new_target = Register::new_target().index(); |
| 6296 | 6294 |
| 6297 ExpectedSnippet<const char*> snippets[] = { | 6295 ExpectedSnippet<const char*> snippets[] = { |
| 6298 {"eval('var x = 10;'); return x;", | 6296 {"eval('var x = 10;'); return x;", |
| 6299 9 * kPointerSize, | 6297 9 * kPointerSize, |
| 6300 1, | 6298 1, |
| 6301 69, | 6299 69, |
| 6302 { | 6300 { |
| 6303 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6301 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6304 U8(1), // | 6302 U8(1), // |
| 6305 B(PushContext), R(0), // | 6303 B(PushContext), R(0), // |
| 6306 B(Ldar), THIS(1), // | 6304 B(Ldar), THIS(1), // |
| 6307 B(StaContextSlot), R(0), U8(first_context_slot), // | 6305 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 6308 B(CreateMappedArguments), // | 6306 B(CreateMappedArguments), // |
| 6309 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6307 B(StaContextSlot), R(0), U8(first_context_slot + 1), // |
| 6310 B(Ldar), R(new_target), // | 6308 B(Ldar), R(new_target), // |
| 6311 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6309 B(StaContextSlot), R(0), U8(first_context_slot + 2), // |
| 6312 B(Mov), R(context), R(3), // | 6310 B(Mov), R(0), R(3), // |
| 6313 B(LdaConstant), U8(0), // | 6311 B(LdaConstant), U8(0), // |
| 6314 B(Star), R(4), // | 6312 B(Star), R(4), // |
| 6315 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6313 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6316 R(3), U8(2), R(1), // | 6314 R(3), U8(2), R(1), // |
| 6317 B(LdaConstant), U8(1), // | 6315 B(LdaConstant), U8(1), // |
| 6318 B(Star), R(3), // | 6316 B(Star), R(3), // |
| 6319 B(Mov), R(1), R(4), // | 6317 B(Mov), R(1), R(4), // |
| 6320 B(Mov), R(3), R(5), // | 6318 B(Mov), R(3), R(5), // |
| 6321 B(Mov), R(closure), R(6), // | 6319 B(Mov), R(closure), R(6), // |
| 6322 B(LdaZero), // | 6320 B(LdaZero), // |
| 6323 B(Star), R(7), // | 6321 B(Star), R(7), // |
| 6324 B(LdaSmi8), U8(10), // | 6322 B(LdaSmi8), U8(10), // |
| 6325 B(Star), R(8), // | 6323 B(Star), R(8), // |
| 6326 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 6324 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
| 6327 U8(5), // | 6325 U8(5), // |
| 6328 B(Star), R(1), // | 6326 B(Star), R(1), // |
| 6329 B(Call), R(1), R(2), U8(1), U8(0), // | 6327 B(Call), R(1), R(2), U8(1), U8(0), // |
| 6330 B(LdaLookupSlot), U8(2), // | 6328 B(LdaLookupSlot), U8(2), // |
| 6331 B(Return), // | 6329 B(Return), // |
| 6332 }, | 6330 }, |
| 6333 3, | 6331 3, |
| 6334 {"eval", "var x = 10;", "x"}}, | 6332 {"eval", "var x = 10;", "x"}}, |
| 6335 {"eval('var x = 10;'); return typeof x;", | 6333 {"eval('var x = 10;'); return typeof x;", |
| 6336 9 * kPointerSize, | 6334 9 * kPointerSize, |
| 6337 1, | 6335 1, |
| 6338 70, | 6336 70, |
| 6339 { | 6337 { |
| 6340 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6338 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6341 U8(1), // | 6339 U8(1), // |
| 6342 B(PushContext), R(0), // | 6340 B(PushContext), R(0), // |
| 6343 B(Ldar), THIS(1), // | 6341 B(Ldar), THIS(1), // |
| 6344 B(StaContextSlot), R(0), U8(first_context_slot), // | 6342 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 6345 B(CreateMappedArguments), // | 6343 B(CreateMappedArguments), // |
| 6346 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6344 B(StaContextSlot), R(0), U8(first_context_slot + 1), // |
| 6347 B(Ldar), R(new_target), // | 6345 B(Ldar), R(new_target), // |
| 6348 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6346 B(StaContextSlot), R(0), U8(first_context_slot + 2), // |
| 6349 B(Mov), R(context), R(3), // | 6347 B(Mov), R(0), R(3), // |
| 6350 B(LdaConstant), U8(0), // | 6348 B(LdaConstant), U8(0), // |
| 6351 B(Star), R(4), // | 6349 B(Star), R(4), // |
| 6352 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6350 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6353 R(3), U8(2), R(1), // | 6351 R(3), U8(2), R(1), // |
| 6354 B(LdaConstant), U8(1), // | 6352 B(LdaConstant), U8(1), // |
| 6355 B(Star), R(3), // | 6353 B(Star), R(3), // |
| 6356 B(Mov), R(1), R(4), // | 6354 B(Mov), R(1), R(4), // |
| 6357 B(Mov), R(3), R(5), // | 6355 B(Mov), R(3), R(5), // |
| 6358 B(Mov), R(closure), R(6), // | 6356 B(Mov), R(closure), R(6), // |
| 6359 B(LdaZero), // | 6357 B(LdaZero), // |
| 6360 B(Star), R(7), // | 6358 B(Star), R(7), // |
| 6361 B(LdaSmi8), U8(10), // | 6359 B(LdaSmi8), U8(10), // |
| 6362 B(Star), R(8), // | 6360 B(Star), R(8), // |
| 6363 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 6361 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
| 6364 U8(5), // | 6362 U8(5), // |
| 6365 B(Star), R(1), // | 6363 B(Star), R(1), // |
| 6366 B(Call), R(1), R(2), U8(1), U8(0), // | 6364 B(Call), R(1), R(2), U8(1), U8(0), // |
| 6367 B(LdaLookupSlotInsideTypeof), U8(2), // | 6365 B(LdaLookupSlotInsideTypeof), U8(2), // |
| 6368 B(TypeOf), // | 6366 B(TypeOf), // |
| 6369 B(Return), // | 6367 B(Return), // |
| 6370 }, | 6368 }, |
| 6371 3, | 6369 3, |
| 6372 {"eval", "var x = 10;", "x"}}, | 6370 {"eval", "var x = 10;", "x"}}, |
| 6373 {"x = 20; return eval('');", | 6371 {"x = 20; return eval('');", |
| 6374 9 * kPointerSize, | 6372 9 * kPointerSize, |
| 6375 1, | 6373 1, |
| 6376 71, | 6374 71, |
| 6377 { | 6375 { |
| 6378 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6376 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6379 U8(1), // | 6377 U8(1), // |
| 6380 B(PushContext), R(0), // | 6378 B(PushContext), R(0), // |
| 6381 B(Ldar), THIS(1), // | 6379 B(Ldar), THIS(1), // |
| 6382 B(StaContextSlot), R(0), U8(first_context_slot), // | 6380 B(StaContextSlot), R(0), U8(first_context_slot), // |
| 6383 B(CreateMappedArguments), // | 6381 B(CreateMappedArguments), // |
| 6384 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6382 B(StaContextSlot), R(0), U8(first_context_slot + 1), // |
| 6385 B(Ldar), R(new_target), // | 6383 B(Ldar), R(new_target), // |
| 6386 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6384 B(StaContextSlot), R(0), U8(first_context_slot + 2), // |
| 6387 B(LdaSmi8), U8(20), // | 6385 B(LdaSmi8), U8(20), // |
| 6388 B(StaLookupSlotSloppy), U8(0), // | 6386 B(StaLookupSlotSloppy), U8(0), // |
| 6389 B(Mov), R(context), R(3), // | 6387 B(Mov), R(0), R(3), // |
| 6390 B(LdaConstant), U8(1), // | 6388 B(LdaConstant), U8(1), // |
| 6391 B(Star), R(4), // | 6389 B(Star), R(4), // |
| 6392 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6390 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6393 R(3), U8(2), R(1), // | 6391 R(3), U8(2), R(1), // |
| 6394 B(LdaConstant), U8(2), // | 6392 B(LdaConstant), U8(2), // |
| 6395 B(Star), R(3), // | 6393 B(Star), R(3), // |
| 6396 B(Mov), R(1), R(4), // | 6394 B(Mov), R(1), R(4), // |
| 6397 B(Mov), R(3), R(5), // | 6395 B(Mov), R(3), R(5), // |
| 6398 B(Mov), R(closure), R(6), // | 6396 B(Mov), R(closure), R(6), // |
| 6399 B(LdaZero), // | 6397 B(LdaZero), // |
| 6400 B(Star), R(7), // | 6398 B(Star), R(7), // |
| 6401 B(LdaSmi8), U8(10), // | 6399 B(LdaSmi8), U8(10), // |
| 6402 B(Star), R(8), // | 6400 B(Star), R(8), // |
| 6403 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 6401 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
| 6404 U8(5), // | 6402 U8(5), // |
| 6405 B(Star), R(1), // | 6403 B(Star), R(1), // |
| 6406 B(Call), R(1), R(2), U8(1), U8(0), // | 6404 B(Call), R(1), R(2), U8(1), U8(0), // |
| 6407 B(Return), // | 6405 B(Return), // |
| 6408 }, | 6406 }, |
| 6409 3, | 6407 3, |
| 6410 {"x", "eval", ""}}, | 6408 {"x", "eval", ""}}, |
| 6411 }; | 6409 }; |
| 6412 | 6410 |
| 6413 for (size_t i = 0; i < arraysize(snippets); i++) { | 6411 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 6414 Handle<BytecodeArray> bytecode_array = | 6412 Handle<BytecodeArray> bytecode_array = |
| 6415 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 6413 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 6416 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6414 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6417 } | 6415 } |
| 6418 } | 6416 } |
| 6419 | 6417 |
| 6420 | 6418 |
| 6421 TEST(CallLookupSlot) { | 6419 TEST(CallLookupSlot) { |
| 6422 InitializedHandleScope handle_scope; | 6420 InitializedHandleScope handle_scope; |
| 6423 BytecodeGeneratorHelper helper; | 6421 BytecodeGeneratorHelper helper; |
| 6424 Zone zone; | 6422 Zone zone; |
| 6425 | 6423 |
| 6426 FeedbackVectorSpec feedback_spec(&zone); | 6424 FeedbackVectorSpec feedback_spec(&zone); |
| 6427 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 6425 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 6428 FeedbackVectorSlot slot2 = feedback_spec.AddCallICSlot(); | 6426 FeedbackVectorSlot slot2 = feedback_spec.AddCallICSlot(); |
| 6429 USE(slot1); | 6427 USE(slot1); |
| 6430 | 6428 |
| 6431 Handle<i::TypeFeedbackVector> vector = | 6429 Handle<i::TypeFeedbackVector> vector = |
| 6432 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 6430 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 6433 | 6431 |
| 6434 int closure = Register::function_closure().index(); | 6432 int closure = Register::function_closure().index(); |
| 6435 int context = Register::function_context().index(); | |
| 6436 int new_target = Register::new_target().index(); | 6433 int new_target = Register::new_target().index(); |
| 6437 | 6434 |
| 6438 ExpectedSnippet<InstanceType> snippets[] = { | 6435 ExpectedSnippet<InstanceType> snippets[] = { |
| 6439 {"g = function(){}; eval(''); return g();", | 6436 {"g = function(){}; eval(''); return g();", |
| 6440 9 * kPointerSize, | 6437 9 * kPointerSize, |
| 6441 1, | 6438 1, |
| 6442 90, | 6439 90, |
| 6443 { | 6440 { |
| 6444 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6441 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6445 U8(1), // | 6442 U8(1), // |
| 6446 B(PushContext), R(0), // | 6443 B(PushContext), R(0), // |
| 6447 B(Ldar), THIS(1), // | 6444 B(Ldar), THIS(1), // |
| 6448 B(StaContextSlot), R(0), U8(4), // | 6445 B(StaContextSlot), R(0), U8(4), // |
| 6449 B(CreateMappedArguments), // | 6446 B(CreateMappedArguments), // |
| 6450 B(StaContextSlot), R(0), U8(5), // | 6447 B(StaContextSlot), R(0), U8(5), // |
| 6451 B(Ldar), R(new_target), // | 6448 B(Ldar), R(new_target), // |
| 6452 B(StaContextSlot), R(0), U8(6), // | 6449 B(StaContextSlot), R(0), U8(6), // |
| 6453 B(CreateClosure), U8(0), U8(0), // | 6450 B(CreateClosure), U8(0), U8(0), // |
| 6454 B(StaLookupSlotSloppy), U8(1), // | 6451 B(StaLookupSlotSloppy), U8(1), // |
| 6455 B(Mov), R(context), R(3), // | 6452 B(Mov), R(0), R(3), // |
| 6456 B(LdaConstant), U8(2), // | 6453 B(LdaConstant), U8(2), // |
| 6457 B(Star), R(4), // | 6454 B(Star), R(4), // |
| 6458 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6455 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6459 R(3), U8(2), R(1), // | 6456 R(3), U8(2), R(1), // |
| 6460 B(LdaConstant), U8(3), // | 6457 B(LdaConstant), U8(3), // |
| 6461 B(Star), R(3), // | 6458 B(Star), R(3), // |
| 6462 B(Mov), R(1), R(4), // | 6459 B(Mov), R(1), R(4), // |
| 6463 B(Mov), R(3), R(5), // | 6460 B(Mov), R(3), R(5), // |
| 6464 B(Mov), R(closure), R(6), // | 6461 B(Mov), R(closure), R(6), // |
| 6465 B(LdaZero), // | 6462 B(LdaZero), // |
| 6466 B(Star), R(7), // | 6463 B(Star), R(7), // |
| 6467 B(LdaSmi8), U8(10), // | 6464 B(LdaSmi8), U8(10), // |
| 6468 B(Star), R(8), // | 6465 B(Star), R(8), // |
| 6469 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 6466 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
| 6470 U8(5), // | 6467 U8(5), // |
| 6471 B(Star), R(1), // | 6468 B(Star), R(1), // |
| 6472 B(Call), R(1), R(2), U8(1), U8(0), // | 6469 B(Call), R(1), R(2), U8(1), U8(0), // |
| 6473 B(Mov), R(context), R(3), // | 6470 B(Mov), R(0), R(3), // |
| 6474 B(LdaConstant), U8(1), // | 6471 B(LdaConstant), U8(1), // |
| 6475 B(Star), R(4), // | 6472 B(Star), R(4), // |
| 6476 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6473 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6477 R(3), U8(2), R(1), // | 6474 R(3), U8(2), R(1), // |
| 6478 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot2)), // | 6475 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot2)), // |
| 6479 B(Return), // | 6476 B(Return), // |
| 6480 }, | 6477 }, |
| 6481 4, | 6478 4, |
| 6482 {InstanceType::SHARED_FUNCTION_INFO_TYPE, | 6479 {InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 6483 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 6480 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 6484 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 6481 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| 6485 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 6482 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 6486 }; | 6483 }; |
| 6487 | 6484 |
| 6488 for (size_t i = 0; i < arraysize(snippets); i++) { | 6485 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 6489 Handle<BytecodeArray> bytecode_array = | 6486 Handle<BytecodeArray> bytecode_array = |
| 6490 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 6487 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 6491 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6488 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6492 } | 6489 } |
| 6493 } | 6490 } |
| 6494 | 6491 |
| 6495 | 6492 |
| 6493 // TODO(mythria): tests for variable/function declaration in lookup slots. |
| 6494 |
| 6496 TEST(LookupSlotInEval) { | 6495 TEST(LookupSlotInEval) { |
| 6497 InitializedHandleScope handle_scope; | 6496 InitializedHandleScope handle_scope; |
| 6498 BytecodeGeneratorHelper helper; | 6497 BytecodeGeneratorHelper helper; |
| 6499 | 6498 |
| 6500 const char* function_prologue = "var f;" | 6499 const char* function_prologue = "var f;" |
| 6501 "var x = 1;" | 6500 "var x = 1;" |
| 6502 "function f1() {" | 6501 "function f1() {" |
| 6503 " eval(\"function t() {"; | 6502 " eval(\"function t() {"; |
| 6504 const char* function_epilogue = " }; f = t; f();\");" | 6503 const char* function_epilogue = " }; f = t; f();\");" |
| 6505 "}" | 6504 "}" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6550 B(Return), // | 6549 B(Return), // |
| 6551 }, | 6550 }, |
| 6552 1, | 6551 1, |
| 6553 {"x"}}, | 6552 {"x"}}, |
| 6554 }; | 6553 }; |
| 6555 | 6554 |
| 6556 for (size_t i = 0; i < arraysize(snippets); i++) { | 6555 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 6557 std::string script = std::string(function_prologue) + | 6556 std::string script = std::string(function_prologue) + |
| 6558 std::string(snippets[i].code_snippet) + | 6557 std::string(snippets[i].code_snippet) + |
| 6559 std::string(function_epilogue); | 6558 std::string(function_epilogue); |
| 6560 // TODO(mythria): use * as filter when function declarations are supported | |
| 6561 // inside eval. | |
| 6562 Handle<BytecodeArray> bytecode_array = | 6559 Handle<BytecodeArray> bytecode_array = |
| 6563 helper.MakeBytecode(script.c_str(), "t", "f"); | 6560 helper.MakeBytecode(script.c_str(), "*", "f"); |
| 6564 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6565 } | 6562 } |
| 6566 } | 6563 } |
| 6567 | 6564 |
| 6568 | 6565 |
| 6569 TEST(LookupSlotWideInEval) { | 6566 TEST(LookupSlotWideInEval) { |
| 6570 InitializedHandleScope handle_scope; | 6567 InitializedHandleScope handle_scope; |
| 6571 BytecodeGeneratorHelper helper; | 6568 BytecodeGeneratorHelper helper; |
| 6572 | 6569 |
| 6573 const char* function_prologue = | 6570 const char* function_prologue = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6647 }, | 6644 }, |
| 6648 257, | 6645 257, |
| 6649 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), | 6646 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), |
| 6650 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 6647 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 6651 }; | 6648 }; |
| 6652 | 6649 |
| 6653 for (size_t i = 0; i < arraysize(snippets); i++) { | 6650 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 6654 std::string script = std::string(function_prologue) + | 6651 std::string script = std::string(function_prologue) + |
| 6655 std::string(snippets[i].code_snippet) + | 6652 std::string(snippets[i].code_snippet) + |
| 6656 std::string(function_epilogue); | 6653 std::string(function_epilogue); |
| 6657 // TODO(mythria): use * as filter when function declarations are supported | |
| 6658 // inside eval. | |
| 6659 Handle<BytecodeArray> bytecode_array = | 6654 Handle<BytecodeArray> bytecode_array = |
| 6660 helper.MakeBytecode(script.c_str(), "t", "f"); | 6655 helper.MakeBytecode(script.c_str(), "*", "f"); |
| 6661 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6656 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6662 } | 6657 } |
| 6663 } | 6658 } |
| 6664 | 6659 |
| 6665 | 6660 |
| 6666 TEST(DeleteLookupSlotInEval) { | 6661 TEST(DeleteLookupSlotInEval) { |
| 6667 InitializedHandleScope handle_scope; | 6662 InitializedHandleScope handle_scope; |
| 6668 BytecodeGeneratorHelper helper; | 6663 BytecodeGeneratorHelper helper; |
| 6669 | 6664 |
| 6670 const char* function_prologue = "var f;" | 6665 const char* function_prologue = "var f;" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6710 }, | 6705 }, |
| 6711 1, | 6706 1, |
| 6712 {"z"}}, | 6707 {"z"}}, |
| 6713 }; | 6708 }; |
| 6714 | 6709 |
| 6715 for (size_t i = 0; i < arraysize(snippets); i++) { | 6710 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 6716 std::string script = std::string(function_prologue) + | 6711 std::string script = std::string(function_prologue) + |
| 6717 std::string(snippets[i].code_snippet) + | 6712 std::string(snippets[i].code_snippet) + |
| 6718 std::string(function_epilogue); | 6713 std::string(function_epilogue); |
| 6719 Handle<BytecodeArray> bytecode_array = | 6714 Handle<BytecodeArray> bytecode_array = |
| 6720 helper.MakeBytecode(script.c_str(), "t", "f"); | 6715 helper.MakeBytecode(script.c_str(), "*", "f"); |
| 6721 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6716 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6722 } | 6717 } |
| 6723 } | 6718 } |
| 6724 | 6719 |
| 6725 } // namespace interpreter | 6720 } // namespace interpreter |
| 6726 } // namespace internal | 6721 } // namespace internal |
| 6727 } // namespace v8 | 6722 } // namespace v8 |
| OLD | NEW |