| 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); | |
| 83 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( | 81 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( |
| 84 isolate->factory()->NewStringFromAsciiChecked("f"), | 82 isolate->factory()->NewStringFromAsciiChecked("f"), |
| 85 isolate->builtins()->CompileLazy(), false); | 83 isolate->builtins()->CompileLazy(), false); |
| 84 SharedFunctionInfo::SetScript(shared, script); |
| 86 shared->set_end_position(source->length()); | 85 shared->set_end_position(source->length()); |
| 87 shared->set_outer_scope_info(ScopeInfo::Empty(isolate)); | 86 shared->set_outer_scope_info(ScopeInfo::Empty(isolate)); |
| 88 shared->set_function_literal_id(1); | 87 shared->set_function_literal_id(1); |
| 89 SharedFunctionInfo::SetScript(shared, script); | |
| 90 return scope.CloseAndEscape(shared); | 88 return scope.CloseAndEscape(shared); |
| 91 } | 89 } |
| 92 | 90 |
| 93 Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { | 91 Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { |
| 94 return Utils::OpenHandle( | 92 return Utils::OpenHandle( |
| 95 *v8::Script::Compile( | 93 *v8::Script::Compile( |
| 96 isolate->GetCurrentContext(), | 94 isolate->GetCurrentContext(), |
| 97 v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) | 95 v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) |
| 98 .ToLocalChecked()) | 96 .ToLocalChecked()) |
| 99 .ToLocalChecked() | 97 .ToLocalChecked() |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 semaphore.Wait(); | 311 semaphore.Wait(); |
| 314 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); | 312 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); |
| 315 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); | 313 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
| 316 | 314 |
| 317 job->ResetOnMainThread(); | 315 job->ResetOnMainThread(); |
| 318 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 316 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
| 319 } | 317 } |
| 320 | 318 |
| 321 } // namespace internal | 319 } // namespace internal |
| 322 } // namespace v8 | 320 } // namespace v8 |
| OLD | NEW |