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 15086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15097 "function foo(i) { return i * i; };" | 15097 "function foo(i) { return i * i; };" |
15098 "bar();"; | 15098 "bar();"; |
15099 | 15099 |
15100 // Run this test in a new isolate to make sure we don't | 15100 // Run this test in a new isolate to make sure we don't |
15101 // have remnants of state from other code. | 15101 // have remnants of state from other code. |
15102 v8::Isolate* isolate = v8::Isolate::New(); | 15102 v8::Isolate* isolate = v8::Isolate::New(); |
15103 isolate->Enter(); | 15103 isolate->Enter(); |
15104 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 15104 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
15105 i::Heap* heap = i_isolate->heap(); | 15105 i::Heap* heap = i_isolate->heap(); |
15106 | 15106 |
| 15107 // Start with a clean slate. |
| 15108 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler_Prepare"); |
| 15109 |
15107 { | 15110 { |
15108 v8::HandleScope scope(isolate); | 15111 v8::HandleScope scope(isolate); |
15109 i::HashMap code(MatchPointers); | 15112 i::HashMap code(MatchPointers); |
15110 code_map = &code; | 15113 code_map = &code; |
15111 | 15114 |
15112 i::HashMap lineinfo(MatchPointers); | 15115 i::HashMap lineinfo(MatchPointers); |
15113 jitcode_line_info = &lineinfo; | 15116 jitcode_line_info = &lineinfo; |
15114 | 15117 |
15115 saw_bar = 0; | 15118 saw_bar = 0; |
15116 move_events = 0; | 15119 move_events = 0; |
(...skipping 13 matching lines...) Expand all Loading... |
15130 i::Handle<i::Code> bar_code(i::Handle<i::JSFunction>::cast( | 15133 i::Handle<i::Code> bar_code(i::Handle<i::JSFunction>::cast( |
15131 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar"))))->code()); | 15134 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar"))))->code()); |
15132 i::Handle<i::Code> foo_code(i::Handle<i::JSFunction>::cast( | 15135 i::Handle<i::Code> foo_code(i::Handle<i::JSFunction>::cast( |
15133 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))))->code()); | 15136 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))))->code()); |
15134 | 15137 |
15135 // Clear the compilation cache to get more wastage. | 15138 // Clear the compilation cache to get more wastage. |
15136 reinterpret_cast<i::Isolate*>(isolate)->compilation_cache()->Clear(); | 15139 reinterpret_cast<i::Isolate*>(isolate)->compilation_cache()->Clear(); |
15137 } | 15140 } |
15138 | 15141 |
15139 // Force code movement. | 15142 // Force code movement. |
15140 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); | 15143 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler_Move"); |
15141 | 15144 |
15142 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 15145 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
15143 | 15146 |
15144 CHECK_LE(kIterations, saw_bar); | 15147 CHECK_LE(kIterations, saw_bar); |
15145 CHECK_LT(0, move_events); | 15148 CHECK_LT(0, move_events); |
15146 | 15149 |
15147 code_map = NULL; | 15150 code_map = NULL; |
15148 jitcode_line_info = NULL; | 15151 jitcode_line_info = NULL; |
15149 } | 15152 } |
15150 | 15153 |
(...skipping 9565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24716 "bar2.js"); | 24719 "bar2.js"); |
24717 } | 24720 } |
24718 | 24721 |
24719 | 24722 |
24720 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { | 24723 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { |
24721 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", | 24724 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", |
24722 " sourceMappingURL=bar2.js\n", "foo();", NULL}; | 24725 " sourceMappingURL=bar2.js\n", "foo();", NULL}; |
24723 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, | 24726 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, |
24724 "bar2.js"); | 24727 "bar2.js"); |
24725 } | 24728 } |
OLD | NEW |