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