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