| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 disasm::Disassembler d(name_converter); | 399 disasm::Disassembler d(name_converter); |
| 400 | 400 |
| 401 if (f->code()->kind() == Code::FUNCTION) { | 401 if (f->code()->kind() == Code::FUNCTION) { |
| 402 Address pc = f->code()->instruction_start(); | 402 Address pc = f->code()->instruction_start(); |
| 403 int decode_size = | 403 int decode_size = |
| 404 Min(f->code()->instruction_size(), | 404 Min(f->code()->instruction_size(), |
| 405 static_cast<int>(f->code()->stack_check_table_offset())); | 405 static_cast<int>(f->code()->stack_check_table_offset())); |
| 406 Address end = pc + decode_size; | 406 Address end = pc + decode_size; |
| 407 | 407 |
| 408 v8::internal::EmbeddedVector<char, 128> decode_buffer; | 408 v8::internal::EmbeddedVector<char, 128> decode_buffer; |
| 409 v8::internal::EmbeddedVector<char, 128> smi_hex_buffer; |
| 410 Smi* smi = Smi::FromInt(12345678); |
| 411 OS::SNPrintF(smi_hex_buffer, "0x%lx", reinterpret_cast<intptr_t>(smi)); |
| 409 while (pc < end) { | 412 while (pc < end) { |
| 410 int num_const = d.ConstantPoolSizeAt(pc); | 413 int num_const = d.ConstantPoolSizeAt(pc); |
| 411 if (num_const >= 0) { | 414 if (num_const >= 0) { |
| 412 pc += (num_const + 1) * kPointerSize; | 415 pc += (num_const + 1) * kPointerSize; |
| 413 } else { | 416 } else { |
| 414 pc += d.InstructionDecode(decode_buffer, pc); | 417 pc += d.InstructionDecode(decode_buffer, pc); |
| 415 CHECK(strstr(decode_buffer.start(), "mov eax,0x178c29c") == NULL); | 418 CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL); |
| 416 CHECK(strstr(decode_buffer.start(), "push 0x178c29c") == NULL); | |
| 417 CHECK(strstr(decode_buffer.start(), "0x178c29c") == NULL); | |
| 418 } | 419 } |
| 419 } | 420 } |
| 420 } | 421 } |
| 421 } | 422 } |
| 422 | 423 |
| 423 | 424 |
| 424 TEST(SplitConstantsInFullCompiler) { | 425 TEST(SplitConstantsInFullCompiler) { |
| 425 v8::HandleScope scope; | 426 v8::HandleScope scope; |
| 426 LocalContext env; | 427 LocalContext env; |
| 427 | 428 |
| 428 CompileRun("function f() { a = 12345678 }; f();"); | 429 CompileRun("function f() { a = 12345678 }; f();"); |
| 429 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 430 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
| 430 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 431 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
| 431 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 432 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
| 432 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 433 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
| 433 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 434 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
| 434 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 435 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
| 435 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 436 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); |
| 436 } | 437 } |
| 437 #endif | 438 #endif |
| OLD | NEW |