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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 NULL, NULL, NO_CACHED_DATA, | 68 NULL, NULL, NO_CACHED_DATA, |
69 NOT_NATIVES_CODE); | 69 NOT_NATIVES_CODE); |
70 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 70 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
71 shared_function, isolate->native_context()); | 71 shared_function, isolate->native_context()); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 static double Inc(Isolate* isolate, int x) { | 75 static double Inc(Isolate* isolate, int x) { |
76 const char* source = "result = %d + 1;"; | 76 const char* source = "result = %d + 1;"; |
77 EmbeddedVector<char, 512> buffer; | 77 EmbeddedVector<char, 512> buffer; |
78 OS::SNPrintF(buffer, source, x); | 78 SNPrintF(buffer, source, x); |
79 | 79 |
80 Handle<JSFunction> fun = Compile(buffer.start()); | 80 Handle<JSFunction> fun = Compile(buffer.start()); |
81 if (fun.is_null()) return -1; | 81 if (fun.is_null()) return -1; |
82 | 82 |
83 Handle<JSObject> global(isolate->context()->global_object()); | 83 Handle<JSObject> global(isolate->context()->global_object()); |
84 Execution::Call(isolate, fun, global, 0, NULL).Check(); | 84 Execution::Call(isolate, fun, global, 0, NULL).Check(); |
85 return GetGlobalProperty("result")->Number(); | 85 return GetGlobalProperty("result")->Number(); |
86 } | 86 } |
87 | 87 |
88 | 88 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (f->code()->kind() == Code::FUNCTION) { | 415 if (f->code()->kind() == Code::FUNCTION) { |
416 Address pc = f->code()->instruction_start(); | 416 Address pc = f->code()->instruction_start(); |
417 int decode_size = | 417 int decode_size = |
418 Min(f->code()->instruction_size(), | 418 Min(f->code()->instruction_size(), |
419 static_cast<int>(f->code()->back_edge_table_offset())); | 419 static_cast<int>(f->code()->back_edge_table_offset())); |
420 Address end = pc + decode_size; | 420 Address end = pc + decode_size; |
421 | 421 |
422 v8::internal::EmbeddedVector<char, 128> decode_buffer; | 422 v8::internal::EmbeddedVector<char, 128> decode_buffer; |
423 v8::internal::EmbeddedVector<char, 128> smi_hex_buffer; | 423 v8::internal::EmbeddedVector<char, 128> smi_hex_buffer; |
424 Smi* smi = Smi::FromInt(12345678); | 424 Smi* smi = Smi::FromInt(12345678); |
425 OS::SNPrintF(smi_hex_buffer, "0x%lx", reinterpret_cast<intptr_t>(smi)); | 425 SNPrintF(smi_hex_buffer, "0x%" V8PRIxPTR, reinterpret_cast<intptr_t>(smi)); |
426 while (pc < end) { | 426 while (pc < end) { |
427 int num_const = d.ConstantPoolSizeAt(pc); | 427 int num_const = d.ConstantPoolSizeAt(pc); |
428 if (num_const >= 0) { | 428 if (num_const >= 0) { |
429 pc += (num_const + 1) * kPointerSize; | 429 pc += (num_const + 1) * kPointerSize; |
430 } else { | 430 } else { |
431 pc += d.InstructionDecode(decode_buffer, pc); | 431 pc += d.InstructionDecode(decode_buffer, pc); |
432 CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL); | 432 CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL); |
433 } | 433 } |
434 } | 434 } |
435 } | 435 } |
436 } | 436 } |
437 | 437 |
438 | 438 |
439 TEST(SplitConstantsInFullCompiler) { | 439 TEST(SplitConstantsInFullCompiler) { |
440 LocalContext context; | 440 LocalContext context; |
441 v8::HandleScope scope(CcTest::isolate()); | 441 v8::HandleScope scope(CcTest::isolate()); |
442 | 442 |
443 CompileRun("function f() { a = 12345678 }; f();"); | 443 CompileRun("function f() { a = 12345678 }; f();"); |
444 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 444 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
445 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 445 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
446 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 446 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
447 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 447 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
448 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 448 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
449 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 449 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
450 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 450 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
451 } | 451 } |
452 #endif | 452 #endif |
OLD | NEW |