OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 return v8::Utils::OpenHandle(*fun); | 360 return v8::Utils::OpenHandle(*fun); |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 static void CheckCodeForUnsafeLiteral(Handle<JSFunction> f) { | 364 static void CheckCodeForUnsafeLiteral(Handle<JSFunction> f) { |
365 // Create a disassembler with default name lookup. | 365 // Create a disassembler with default name lookup. |
366 disasm::NameConverter name_converter; | 366 disasm::NameConverter name_converter; |
367 disasm::Disassembler d(name_converter); | 367 disasm::Disassembler d(name_converter); |
368 | 368 |
369 if (f->code()->kind() == Code::FUNCTION) { | 369 if (f->code()->kind() == Code::FUNCTION) { |
| 370 #ifdef DEBUG |
| 371 f->code()->PrintLn(); |
| 372 #endif |
370 Address pc = f->code()->instruction_start(); | 373 Address pc = f->code()->instruction_start(); |
371 int decode_size = | 374 int decode_size = |
372 Min(f->code()->instruction_size(), | 375 Min(f->code()->instruction_size(), |
373 static_cast<int>(f->code()->stack_check_table_offset())); | 376 static_cast<int>(f->code()->stack_check_table_offset())); |
374 Address end = pc + decode_size; | 377 Address end = pc + decode_size; |
375 | 378 |
376 v8::internal::EmbeddedVector<char, 128> decode_buffer; | 379 v8::internal::EmbeddedVector<char, 128> decode_buffer; |
377 while (pc < end) { | 380 while (pc < end) { |
| 381 PrintF("%08x\n", reinterpret_cast<intptr_t>(pc)); |
378 pc += d.InstructionDecode(decode_buffer, pc); | 382 pc += d.InstructionDecode(decode_buffer, pc); |
379 CHECK(strstr(decode_buffer.start(), "mov eax,0x178c29c") == NULL); | 383 CHECK(strstr(decode_buffer.start(), "mov eax,0x178c29c") == NULL); |
380 CHECK(strstr(decode_buffer.start(), "push 0x178c29c") == NULL); | 384 CHECK(strstr(decode_buffer.start(), "push 0x178c29c") == NULL); |
381 CHECK(strstr(decode_buffer.start(), "0x178c29c") == NULL); | 385 CHECK(strstr(decode_buffer.start(), "0x178c29c") == NULL); |
382 } | 386 } |
383 } | 387 } |
384 } | 388 } |
385 | 389 |
386 | 390 |
387 TEST(SplitConstantsInFullCompiler) { | 391 TEST(SplitConstantsInFullCompiler) { |
388 v8::HandleScope scope; | 392 v8::HandleScope scope; |
389 LocalContext env; | 393 LocalContext env; |
390 | 394 |
391 CompileRun("function f() { a = 12345678 }; f();"); | 395 CompileRun("function f() { a = 12345678 }; f();"); |
392 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 396 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
393 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 397 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
394 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 398 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
395 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 399 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
396 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 400 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
397 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 401 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
398 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 402 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
399 } | 403 } |
400 #endif | 404 #endif |
OLD | NEW |