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 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class AstValueFactory; | 15 class AstValueFactory; |
16 class ScriptData; | |
17 class HydrogenCodeStub; | 16 class HydrogenCodeStub; |
18 | 17 |
19 // ParseRestriction is used to restrict the set of valid statements in a | 18 // ParseRestriction is used to restrict the set of valid statements in a |
20 // unit of compilation. Restriction violations cause a syntax error. | 19 // unit of compilation. Restriction violations cause a syntax error. |
21 enum ParseRestriction { | 20 enum ParseRestriction { |
22 NO_PARSE_RESTRICTION, // All expressions are allowed. | 21 NO_PARSE_RESTRICTION, // All expressions are allowed. |
23 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. | 22 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. |
24 }; | 23 }; |
25 | 24 |
26 enum CachedDataMode { | 25 enum CachedDataMode { |
27 NO_CACHED_DATA, | 26 NO_CACHED_DATA, |
28 CONSUME_CACHED_DATA, | 27 CONSUME_CACHED_DATA, |
29 PRODUCE_CACHED_DATA | 28 PRODUCE_CACHED_DATA |
30 }; | 29 }; |
31 | 30 |
32 struct OffsetRange { | 31 struct OffsetRange { |
33 OffsetRange(int from, int to) : from(from), to(to) {} | 32 OffsetRange(int from, int to) : from(from), to(to) {} |
34 int from; | 33 int from; |
35 int to; | 34 int to; |
36 }; | 35 }; |
37 | 36 |
| 37 |
| 38 class ScriptData { |
| 39 public: |
| 40 ScriptData(const byte* data, int length); |
| 41 ~ScriptData() { |
| 42 if (owns_data_) DeleteArray(data_); |
| 43 } |
| 44 |
| 45 const byte* data() const { return data_; } |
| 46 int length() const { return length_; } |
| 47 |
| 48 void AcquireDataOwnership() { |
| 49 ASSERT(!owns_data_); |
| 50 owns_data_ = true; |
| 51 } |
| 52 |
| 53 void ReleaseDataOwnership() { |
| 54 ASSERT(owns_data_); |
| 55 owns_data_ = false; |
| 56 } |
| 57 |
| 58 private: |
| 59 bool owns_data_; |
| 60 const byte* data_; |
| 61 int length_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(ScriptData); |
| 64 }; |
| 65 |
| 66 |
38 // CompilationInfo encapsulates some information known at compile time. It | 67 // CompilationInfo encapsulates some information known at compile time. It |
39 // is constructed based on the resources available at compile-time. | 68 // is constructed based on the resources available at compile-time. |
40 class CompilationInfo { | 69 class CompilationInfo { |
41 public: | 70 public: |
42 CompilationInfo(Handle<JSFunction> closure, Zone* zone); | 71 CompilationInfo(Handle<JSFunction> closure, Zone* zone); |
43 virtual ~CompilationInfo(); | 72 virtual ~CompilationInfo(); |
44 | 73 |
45 Isolate* isolate() const { | 74 Isolate* isolate() const { |
46 return isolate_; | 75 return isolate_; |
47 } | 76 } |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 private: | 744 private: |
716 const char* name_; | 745 const char* name_; |
717 CompilationInfo* info_; | 746 CompilationInfo* info_; |
718 Zone zone_; | 747 Zone zone_; |
719 unsigned info_zone_start_allocation_size_; | 748 unsigned info_zone_start_allocation_size_; |
720 base::ElapsedTimer timer_; | 749 base::ElapsedTimer timer_; |
721 | 750 |
722 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 751 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
723 }; | 752 }; |
724 | 753 |
725 | |
726 } } // namespace v8::internal | 754 } } // namespace v8::internal |
727 | 755 |
728 #endif // V8_COMPILER_H_ | 756 #endif // V8_COMPILER_H_ |
OLD | NEW |