OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 : owns_data_(false), rejected_(false), data_(data), length_(length) { | 32 : owns_data_(false), rejected_(false), data_(data), length_(length) { |
33 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) { | 33 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) { |
34 byte* copy = NewArray<byte>(length); | 34 byte* copy = NewArray<byte>(length); |
35 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment)); | 35 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment)); |
36 CopyBytes(copy, data, length); | 36 CopyBytes(copy, data, length); |
37 data_ = copy; | 37 data_ = copy; |
38 AcquireDataOwnership(); | 38 AcquireDataOwnership(); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 | |
43 ParseInfo::ParseInfo(Zone* zone) | 42 ParseInfo::ParseInfo(Zone* zone) |
44 : zone_(zone), | 43 : zone_(zone), |
45 flags_(0), | 44 flags_(0), |
46 source_stream_(nullptr), | 45 source_stream_(nullptr), |
47 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), | 46 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), |
48 extension_(nullptr), | 47 extension_(nullptr), |
49 compile_options_(ScriptCompiler::kNoCompileOptions), | 48 compile_options_(ScriptCompiler::kNoCompileOptions), |
50 script_scope_(nullptr), | 49 script_scope_(nullptr), |
51 unicode_cache_(nullptr), | 50 unicode_cache_(nullptr), |
52 stack_limit_(0), | 51 stack_limit_(0), |
53 hash_seed_(0), | 52 hash_seed_(0), |
| 53 isolate_(nullptr), |
54 cached_data_(nullptr), | 54 cached_data_(nullptr), |
55 ast_value_factory_(nullptr), | 55 ast_value_factory_(nullptr), |
56 literal_(nullptr), | 56 literal_(nullptr), |
57 scope_(nullptr) {} | 57 scope_(nullptr) {} |
58 | 58 |
59 | |
60 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function) | 59 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function) |
61 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) { | 60 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) { |
62 set_closure(function); | |
63 set_context(Handle<Context>(function->context())); | 61 set_context(Handle<Context>(function->context())); |
64 } | 62 } |
65 | 63 |
66 | 64 |
67 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) | 65 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) |
68 : ParseInfo(zone) { | 66 : ParseInfo(zone) { |
69 isolate_ = shared->GetIsolate(); | 67 isolate_ = shared->GetIsolate(); |
70 | 68 |
71 set_lazy(); | 69 set_lazy(); |
72 set_hash_seed(isolate_->heap()->HashSeed()); | 70 set_hash_seed(isolate_->heap()->HashSeed()); |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 | 1039 |
1042 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1040 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
1043 | 1041 |
1044 // Place holder for the result. | 1042 // Place holder for the result. |
1045 FunctionLiteral* result = NULL; | 1043 FunctionLiteral* result = NULL; |
1046 | 1044 |
1047 { | 1045 { |
1048 // Parse the function literal. | 1046 // Parse the function literal. |
1049 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); | 1047 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); |
1050 info->set_script_scope(scope); | 1048 info->set_script_scope(scope); |
1051 if (!info->closure().is_null()) { | 1049 if (!info->context().is_null()) { |
1052 // Ok to use Isolate here, since lazy function parsing is only done in the | 1050 // Ok to use Isolate here, since lazy function parsing is only done in the |
1053 // main thread. | 1051 // main thread. |
1054 DCHECK(parsing_on_main_thread_); | 1052 DCHECK(parsing_on_main_thread_); |
1055 scope = Scope::DeserializeScopeChain(isolate, zone(), | 1053 scope = Scope::DeserializeScopeChain(isolate, zone(), *info->context(), |
1056 info->closure()->context(), scope); | 1054 scope); |
1057 } | 1055 } |
1058 original_scope_ = scope; | 1056 original_scope_ = scope; |
1059 AstNodeFactory function_factory(ast_value_factory()); | 1057 AstNodeFactory function_factory(ast_value_factory()); |
1060 FunctionState function_state(&function_state_, &scope_, scope, | 1058 FunctionState function_state(&function_state_, &scope_, scope, |
1061 shared_info->kind(), &function_factory); | 1059 shared_info->kind(), &function_factory); |
1062 DCHECK(is_sloppy(scope->language_mode()) || | 1060 DCHECK(is_sloppy(scope->language_mode()) || |
1063 is_strict(info->language_mode())); | 1061 is_strict(info->language_mode())); |
1064 DCHECK(info->language_mode() == shared_info->language_mode()); | 1062 DCHECK(info->language_mode() == shared_info->language_mode()); |
1065 FunctionLiteral::FunctionType function_type = | 1063 FunctionLiteral::FunctionType function_type = |
1066 ComputeFunctionType(shared_info); | 1064 ComputeFunctionType(shared_info); |
(...skipping 5722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6789 try_block, target); | 6787 try_block, target); |
6790 final_loop = target; | 6788 final_loop = target; |
6791 } | 6789 } |
6792 | 6790 |
6793 return final_loop; | 6791 return final_loop; |
6794 } | 6792 } |
6795 | 6793 |
6796 | 6794 |
6797 } // namespace internal | 6795 } // namespace internal |
6798 } // namespace v8 | 6796 } // namespace v8 |
OLD | NEW |