Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: src/fast-codegen.h

Issue 3152016: Remove experimental fast-codegen. We are no longer working on this (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler.cc ('k') | src/fast-codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_FAST_CODEGEN_H_
29 #define V8_FAST_CODEGEN_H_
30
31 #if V8_TARGET_ARCH_IA32
32 #include "ia32/fast-codegen-ia32.h"
33 #else
34
35 #include "v8.h"
36
37 #include "ast.h"
38 #include "compiler.h"
39 #include "list.h"
40
41 namespace v8 {
42 namespace internal {
43
44 class FastCodeGenSyntaxChecker: public AstVisitor {
45 public:
46 explicit FastCodeGenSyntaxChecker()
47 : info_(NULL), has_supported_syntax_(true) {
48 }
49
50 void Check(CompilationInfo* info);
51
52 CompilationInfo* info() { return info_; }
53 bool has_supported_syntax() { return has_supported_syntax_; }
54
55 private:
56 void VisitDeclarations(ZoneList<Declaration*>* decls);
57 void VisitStatements(ZoneList<Statement*>* stmts);
58
59 // AST node visit functions.
60 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
61 AST_NODE_LIST(DECLARE_VISIT)
62 #undef DECLARE_VISIT
63
64 CompilationInfo* info_;
65 bool has_supported_syntax_;
66
67 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker);
68 };
69
70
71 class FastCodeGenerator: public AstVisitor {
72 public:
73 explicit FastCodeGenerator(MacroAssembler* masm)
74 : masm_(masm), info_(NULL), destination_(no_reg), smi_bits_(0) {
75 }
76
77 static Handle<Code> MakeCode(CompilationInfo* info);
78
79 void Generate(CompilationInfo* compilation_info);
80
81 private:
82 MacroAssembler* masm() { return masm_; }
83 CompilationInfo* info() { return info_; }
84
85 Register destination() { return destination_; }
86 void set_destination(Register reg) { destination_ = reg; }
87
88 FunctionLiteral* function() { return info_->function(); }
89 Scope* scope() { return info_->scope(); }
90
91 // Platform-specific fixed registers, all guaranteed distinct.
92 Register accumulator0();
93 Register accumulator1();
94 Register scratch0();
95 Register scratch1();
96 Register scratch2();
97 Register receiver_reg();
98 Register context_reg();
99
100 Register other_accumulator(Register reg) {
101 ASSERT(reg.is(accumulator0()) || reg.is(accumulator1()));
102 return (reg.is(accumulator0())) ? accumulator1() : accumulator0();
103 }
104
105 // Flags are true if the respective register is statically known to hold a
106 // smi. We do not track every register, only the accumulator registers.
107 bool is_smi(Register reg) {
108 ASSERT(!reg.is(no_reg));
109 return (smi_bits_ & reg.bit()) != 0;
110 }
111 void set_as_smi(Register reg) {
112 ASSERT(!reg.is(no_reg));
113 smi_bits_ = smi_bits_ | reg.bit();
114 }
115 void clear_as_smi(Register reg) {
116 ASSERT(!reg.is(no_reg));
117 smi_bits_ = smi_bits_ & ~reg.bit();
118 }
119
120 // AST node visit functions.
121 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
122 AST_NODE_LIST(DECLARE_VISIT)
123 #undef DECLARE_VISIT
124
125 // Emit code to load the receiver from the stack into receiver_reg.
126 void EmitLoadReceiver();
127
128 // Emit code to load a global variable directly from a global property
129 // cell into the destination register.
130 void EmitGlobalVariableLoad(Handle<Object> cell);
131
132 // Emit a store to an own property of this. The stored value is expected
133 // in accumulator0 and the receiver in receiver_reg. The receiver
134 // register is preserved and the result (the stored value) is left in the
135 // destination register.
136 void EmitThisPropertyStore(Handle<String> name);
137
138 // Emit a load from an own property of this. The receiver is expected in
139 // receiver_reg. The receiver register is preserved and the result is
140 // left in the destination register.
141 void EmitThisPropertyLoad(Handle<String> name);
142
143 // Emit a bitwise or operation. The left operand is in accumulator1 and
144 // the right is in accumulator0. The result should be left in the
145 // destination register.
146 void EmitBitOr();
147
148 MacroAssembler* masm_;
149 CompilationInfo* info_;
150 Register destination_;
151 uint32_t smi_bits_;
152
153 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator);
154 };
155
156
157 } } // namespace v8::internal
158
159 #endif // V8_TARGET_ARCH_IA32
160
161 #endif // V8_FAST_CODEGEN_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/fast-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698