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 "src/parsing/parse-info.h" | 5 #include "src/parsing/parse-info.h" |
6 | 6 |
7 #include "src/ast/ast-value-factory.h" | 7 #include "src/ast/ast-value-factory.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/zone/zone.h" | |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 ParseInfo::ParseInfo(AccountingAllocator* zone_allocator) | 14 ParseInfo::ParseInfo(Zone* zone) |
16 : zone_(std::make_shared<Zone>(zone_allocator, ZONE_NAME)), | 15 : zone_(zone), |
17 flags_(0), | 16 flags_(0), |
18 source_stream_(nullptr), | 17 source_stream_(nullptr), |
19 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), | 18 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), |
20 character_stream_(nullptr), | 19 character_stream_(nullptr), |
21 extension_(nullptr), | 20 extension_(nullptr), |
22 compile_options_(ScriptCompiler::kNoCompileOptions), | 21 compile_options_(ScriptCompiler::kNoCompileOptions), |
23 script_scope_(nullptr), | 22 script_scope_(nullptr), |
24 asm_function_scope_(nullptr), | 23 asm_function_scope_(nullptr), |
25 unicode_cache_(nullptr), | 24 unicode_cache_(nullptr), |
26 stack_limit_(0), | 25 stack_limit_(0), |
27 hash_seed_(0), | 26 hash_seed_(0), |
28 compiler_hints_(0), | 27 compiler_hints_(0), |
29 start_position_(0), | 28 start_position_(0), |
30 end_position_(0), | 29 end_position_(0), |
31 function_literal_id_(FunctionLiteral::kIdTypeInvalid), | 30 function_literal_id_(FunctionLiteral::kIdTypeInvalid), |
32 max_function_literal_id_(FunctionLiteral::kIdTypeInvalid), | 31 max_function_literal_id_(FunctionLiteral::kIdTypeInvalid), |
33 isolate_(nullptr), | 32 isolate_(nullptr), |
34 cached_data_(nullptr), | 33 cached_data_(nullptr), |
35 ast_value_factory_(nullptr), | 34 ast_value_factory_(nullptr), |
36 function_name_(nullptr), | 35 function_name_(nullptr), |
37 literal_(nullptr) {} | 36 literal_(nullptr) {} |
38 | 37 |
39 ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) | 38 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) |
40 : ParseInfo(shared->GetIsolate()->allocator()) { | 39 : ParseInfo(zone) { |
41 isolate_ = shared->GetIsolate(); | 40 isolate_ = shared->GetIsolate(); |
42 | 41 |
43 set_toplevel(shared->is_toplevel()); | 42 set_toplevel(shared->is_toplevel()); |
44 set_allow_lazy_parsing(FLAG_lazy_inner_functions); | 43 set_allow_lazy_parsing(FLAG_lazy_inner_functions); |
45 set_hash_seed(isolate_->heap()->HashSeed()); | 44 set_hash_seed(isolate_->heap()->HashSeed()); |
46 set_is_named_expression(shared->is_named_expression()); | 45 set_is_named_expression(shared->is_named_expression()); |
47 set_calls_eval(shared->scope_info()->CallsEval()); | 46 set_calls_eval(shared->scope_info()->CallsEval()); |
48 set_compiler_hints(shared->compiler_hints()); | 47 set_compiler_hints(shared->compiler_hints()); |
49 set_start_position(shared->start_position()); | 48 set_start_position(shared->start_position()); |
50 set_end_position(shared->end_position()); | 49 set_end_position(shared->end_position()); |
51 function_literal_id_ = shared->function_literal_id(); | 50 function_literal_id_ = shared->function_literal_id(); |
52 set_stack_limit(isolate_->stack_guard()->real_climit()); | 51 set_stack_limit(isolate_->stack_guard()->real_climit()); |
53 set_unicode_cache(isolate_->unicode_cache()); | 52 set_unicode_cache(isolate_->unicode_cache()); |
54 set_language_mode(shared->language_mode()); | 53 set_language_mode(shared->language_mode()); |
55 set_shared_info(shared); | 54 set_shared_info(shared); |
56 set_module(shared->kind() == FunctionKind::kModule); | 55 set_module(shared->kind() == FunctionKind::kModule); |
57 | 56 |
58 Handle<Script> script(Script::cast(shared->script())); | 57 Handle<Script> script(Script::cast(shared->script())); |
59 set_script(script); | 58 set_script(script); |
60 set_native(script->type() == Script::TYPE_NATIVE); | 59 set_native(script->type() == Script::TYPE_NATIVE); |
61 set_eval(script->compilation_type() == Script::COMPILATION_TYPE_EVAL); | 60 set_eval(script->compilation_type() == Script::COMPILATION_TYPE_EVAL); |
62 | 61 |
63 Handle<HeapObject> scope_info(shared->outer_scope_info()); | 62 Handle<HeapObject> scope_info(shared->outer_scope_info()); |
64 if (!scope_info->IsTheHole(isolate()) && | 63 if (!scope_info->IsTheHole(isolate()) && |
65 Handle<ScopeInfo>::cast(scope_info)->length() > 0) { | 64 Handle<ScopeInfo>::cast(scope_info)->length() > 0) { |
66 set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info)); | 65 set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info)); |
67 } | 66 } |
68 } | 67 } |
69 | 68 |
70 ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared, | 69 ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) { |
71 std::shared_ptr<Zone> zone) | |
72 : ParseInfo(shared) { | |
73 zone_.swap(zone); | |
74 } | |
75 | |
76 ParseInfo::ParseInfo(Handle<Script> script) | |
77 : ParseInfo(script->GetIsolate()->allocator()) { | |
78 isolate_ = script->GetIsolate(); | 70 isolate_ = script->GetIsolate(); |
79 | 71 |
80 set_allow_lazy_parsing(); | 72 set_allow_lazy_parsing(); |
81 set_toplevel(); | 73 set_toplevel(); |
82 set_hash_seed(isolate_->heap()->HashSeed()); | 74 set_hash_seed(isolate_->heap()->HashSeed()); |
83 set_stack_limit(isolate_->stack_guard()->real_climit()); | 75 set_stack_limit(isolate_->stack_guard()->real_climit()); |
84 set_unicode_cache(isolate_->unicode_cache()); | 76 set_unicode_cache(isolate_->unicode_cache()); |
85 set_script(script); | 77 set_script(script); |
86 | 78 |
87 set_native(script->type() == Script::TYPE_NATIVE); | 79 set_native(script->type() == Script::TYPE_NATIVE); |
(...skipping 19 matching lines...) Expand all Loading... |
107 } | 99 } |
108 | 100 |
109 #ifdef DEBUG | 101 #ifdef DEBUG |
110 bool ParseInfo::script_is_native() const { | 102 bool ParseInfo::script_is_native() const { |
111 return script_->type() == Script::TYPE_NATIVE; | 103 return script_->type() == Script::TYPE_NATIVE; |
112 } | 104 } |
113 #endif // DEBUG | 105 #endif // DEBUG |
114 | 106 |
115 } // namespace internal | 107 } // namespace internal |
116 } // namespace v8 | 108 } // namespace v8 |
OLD | NEW |