OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "include/v8.h" | 7 #include "include/v8.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 HandleScope scope(isolate); | 71 HandleScope scope(isolate); |
72 Handle<String> source; | 72 Handle<String> source; |
73 if (maybe_resource) { | 73 if (maybe_resource) { |
74 source = isolate->factory() | 74 source = isolate->factory() |
75 ->NewExternalStringFromOneByte(maybe_resource) | 75 ->NewExternalStringFromOneByte(maybe_resource) |
76 .ToHandleChecked(); | 76 .ToHandleChecked(); |
77 } else { | 77 } else { |
78 source = isolate->factory()->NewStringFromAsciiChecked(test_script); | 78 source = isolate->factory()->NewStringFromAsciiChecked(test_script); |
79 } | 79 } |
80 Handle<Script> script = isolate->factory()->NewScript(source); | 80 Handle<Script> script = isolate->factory()->NewScript(source); |
| 81 Handle<FixedArray> infos = isolate->factory()->NewFixedArray(3); |
| 82 script->set_shared_function_infos(*infos); |
81 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( | 83 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( |
82 isolate->factory()->NewStringFromAsciiChecked("f"), | 84 isolate->factory()->NewStringFromAsciiChecked("f"), |
83 isolate->builtins()->CompileLazy(), false); | 85 isolate->builtins()->CompileLazy(), false); |
84 SharedFunctionInfo::SetScript(shared, script); | |
85 shared->set_end_position(source->length()); | 86 shared->set_end_position(source->length()); |
86 shared->set_outer_scope_info(ScopeInfo::Empty(isolate)); | 87 shared->set_outer_scope_info(ScopeInfo::Empty(isolate)); |
87 shared->set_function_literal_id(1); | 88 shared->set_function_literal_id(1); |
| 89 SharedFunctionInfo::SetScript(shared, script); |
88 return scope.CloseAndEscape(shared); | 90 return scope.CloseAndEscape(shared); |
89 } | 91 } |
90 | 92 |
91 Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { | 93 Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { |
92 return Utils::OpenHandle( | 94 return Utils::OpenHandle( |
93 *v8::Script::Compile( | 95 *v8::Script::Compile( |
94 isolate->GetCurrentContext(), | 96 isolate->GetCurrentContext(), |
95 v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) | 97 v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) |
96 .ToLocalChecked()) | 98 .ToLocalChecked()) |
97 .ToLocalChecked() | 99 .ToLocalChecked() |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 semaphore.Wait(); | 313 semaphore.Wait(); |
312 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); | 314 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); |
313 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); | 315 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
314 | 316 |
315 job->ResetOnMainThread(); | 317 job->ResetOnMainThread(); |
316 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 318 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
317 } | 319 } |
318 | 320 |
319 } // namespace internal | 321 } // namespace internal |
320 } // namespace v8 | 322 } // namespace v8 |
OLD | NEW |