OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void set_state(CodeGenState* state) { state_ = state; } | 147 void set_state(CodeGenState* state) { state_ = state; } |
148 | 148 |
149 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } | 149 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
150 | 150 |
151 static const int kUnknownIntValue = -1; | 151 static const int kUnknownIntValue = -1; |
152 | 152 |
153 // Number of instructions used for the JS return sequence. The constant is | 153 // Number of instructions used for the JS return sequence. The constant is |
154 // used by the debugger to patch the JS return sequence. | 154 // used by the debugger to patch the JS return sequence. |
155 static const int kJSReturnSequenceLength = 6; | 155 static const int kJSReturnSequenceLength = 6; |
156 | 156 |
| 157 // If the name is an inline runtime function call return the number of |
| 158 // expected arguments. Otherwise return -1. |
| 159 static int InlineRuntimeCallArgumentsCount(Handle<String> name); |
| 160 |
157 private: | 161 private: |
158 // Construction/Destruction. | 162 // Construction/Destruction. |
159 explicit CodeGenerator(MacroAssembler* masm); | 163 explicit CodeGenerator(MacroAssembler* masm); |
160 | 164 |
161 // Accessors. | 165 // Accessors. |
162 inline bool is_eval(); | 166 inline bool is_eval(); |
163 inline Scope* scope(); | 167 inline Scope* scope(); |
164 | 168 |
165 // Generating deferred code. | 169 // Generating deferred code. |
166 void ProcessDeferred(); | 170 void ProcessDeferred(); |
(...skipping 14 matching lines...) Expand all Loading... |
181 void Visit##type(type* node); | 185 void Visit##type(type* node); |
182 AST_NODE_LIST(DEF_VISIT) | 186 AST_NODE_LIST(DEF_VISIT) |
183 #undef DEF_VISIT | 187 #undef DEF_VISIT |
184 | 188 |
185 // Main code generation function | 189 // Main code generation function |
186 void Generate(CompilationInfo* info); | 190 void Generate(CompilationInfo* info); |
187 | 191 |
188 struct InlineRuntimeLUT { | 192 struct InlineRuntimeLUT { |
189 void (CodeGenerator::*method)(ZoneList<Expression*>*); | 193 void (CodeGenerator::*method)(ZoneList<Expression*>*); |
190 const char* name; | 194 const char* name; |
| 195 int nargs; |
191 }; | 196 }; |
192 | 197 |
193 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name); | 198 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name); |
194 bool CheckForInlineRuntimeCall(CallRuntime* node); | 199 bool CheckForInlineRuntimeCall(CallRuntime* node); |
195 static bool PatchInlineRuntimeEntry(Handle<String> name, | 200 static bool PatchInlineRuntimeEntry(Handle<String> name, |
196 const InlineRuntimeLUT& new_entry, | 201 const InlineRuntimeLUT& new_entry, |
197 InlineRuntimeLUT* old_entry); | 202 InlineRuntimeLUT* old_entry); |
198 | 203 |
199 static Handle<Code> ComputeLazyCompile(int argc); | 204 static Handle<Code> ComputeLazyCompile(int argc); |
200 void ProcessDeclarations(ZoneList<Declaration*>* declarations); | 205 void ProcessDeclarations(ZoneList<Declaration*>* declarations); |
201 | 206 |
202 Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop); | 207 Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop); |
203 | 208 |
204 // Declare global variables and functions in the given array of | 209 // Declare global variables and functions in the given array of |
205 // name/value pairs. | 210 // name/value pairs. |
206 void DeclareGlobals(Handle<FixedArray> pairs); | 211 void DeclareGlobals(Handle<FixedArray> pairs); |
207 | 212 |
208 // Support for type checks. | 213 // Support for type checks. |
209 void GenerateIsSmi(ZoneList<Expression*>* args); | 214 void GenerateIsSmi(ZoneList<Expression*>* args); |
210 void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); | 215 void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); |
211 void GenerateIsArray(ZoneList<Expression*>* args); | 216 void GenerateIsArray(ZoneList<Expression*>* args); |
212 void GenerateIsRegExp(ZoneList<Expression*>* args); | 217 void GenerateIsRegExp(ZoneList<Expression*>* args); |
213 | 218 |
214 // Support for construct call checks. | 219 // Support for construct call checks. |
215 void GenerateIsConstructCall(ZoneList<Expression*>* args); | 220 void GenerateIsConstructCall(ZoneList<Expression*>* args); |
216 | 221 |
217 // Support for arguments.length and arguments[?]. | 222 // Support for arguments.length and arguments[?]. |
218 void GenerateArgumentsLength(ZoneList<Expression*>* args); | 223 void GenerateArgumentsLength(ZoneList<Expression*>* args); |
219 void GenerateArgumentsAccess(ZoneList<Expression*>* args); | 224 void GenerateArguments(ZoneList<Expression*>* args); |
220 | 225 |
221 // Support for accessing the class and value fields of an object. | 226 // Support for accessing the class and value fields of an object. |
222 void GenerateClassOf(ZoneList<Expression*>* args); | 227 void GenerateClassOf(ZoneList<Expression*>* args); |
223 void GenerateValueOf(ZoneList<Expression*>* args); | 228 void GenerateValueOf(ZoneList<Expression*>* args); |
224 void GenerateSetValueOf(ZoneList<Expression*>* args); | 229 void GenerateSetValueOf(ZoneList<Expression*>* args); |
225 | 230 |
226 // Fast support for charCodeAt(n). | 231 // Fast support for charCodeAt(n). |
227 void GenerateFastCharCodeAt(ZoneList<Expression*>* args); | 232 void GenerateFastCharCodeAt(ZoneList<Expression*>* args); |
228 | 233 |
229 // Fast support for string.charAt(n) and string[n]. | 234 // Fast support for string.charAt(n) and string[n]. |
230 void GenerateCharFromCode(ZoneList<Expression*>* args); | 235 void GenerateCharFromCode(ZoneList<Expression*>* args); |
231 | 236 |
232 // Fast support for object equality testing. | 237 // Fast support for object equality testing. |
233 void GenerateObjectEquals(ZoneList<Expression*>* args); | 238 void GenerateObjectEquals(ZoneList<Expression*>* args); |
234 | 239 |
235 void GenerateLog(ZoneList<Expression*>* args); | 240 void GenerateLog(ZoneList<Expression*>* args); |
236 | 241 |
237 // Fast support for Math.random(). | 242 // Fast support for Math.random(). |
238 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); | 243 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); |
239 | 244 |
240 void GenerateIsObject(ZoneList<Expression*>* args); | 245 void GenerateIsObject(ZoneList<Expression*>* args); |
241 void GenerateIsFunction(ZoneList<Expression*>* args); | 246 void GenerateIsFunction(ZoneList<Expression*>* args); |
242 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); | 247 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); |
243 void GenerateStringAdd(ZoneList<Expression*>* args); | 248 void GenerateStringAdd(ZoneList<Expression*>* args); |
244 void GenerateSubString(ZoneList<Expression*>* args); | 249 void GenerateSubString(ZoneList<Expression*>* args); |
245 void GenerateStringCompare(ZoneList<Expression*>* args); | 250 void GenerateStringCompare(ZoneList<Expression*>* args); |
246 void GenerateRegExpExec(ZoneList<Expression*>* args); | 251 void GenerateRegExpExec(ZoneList<Expression*>* args); |
247 void GenerateNumberToString(ZoneList<Expression*>* args); | 252 void GenerateNumberToString(ZoneList<Expression*>* args); |
248 | 253 |
249 // Fast support for Math.pow(). | 254 // Fast call to math functions. |
250 void GenerateMathPow(ZoneList<Expression*>* args); | 255 void GenerateMathPow(ZoneList<Expression*>* args); |
251 // Fast support for Math.sqrt(). | 256 void GenerateMathSin(ZoneList<Expression*>* args); |
252 void GenerateMathPow(ZoneList<Expression*>* args); | 257 void GenerateMathCos(ZoneList<Expression*>* args); |
253 | 258 void GenerateMathSqrt(ZoneList<Expression*>* args); |
254 | |
255 // Fast support for Math.sin and Math.cos. | |
256 inline void GenerateMathSin(ZoneList<Expression*>* args); | |
257 inline void GenerateMathCos(ZoneList<Expression*>* args); | |
258 | 259 |
259 // Simple condition analysis. | 260 // Simple condition analysis. |
260 enum ConditionAnalysis { | 261 enum ConditionAnalysis { |
261 ALWAYS_TRUE, | 262 ALWAYS_TRUE, |
262 ALWAYS_FALSE, | 263 ALWAYS_FALSE, |
263 DONT_KNOW | 264 DONT_KNOW |
264 }; | 265 }; |
265 ConditionAnalysis AnalyzeCondition(Expression* cond); | 266 ConditionAnalysis AnalyzeCondition(Expression* cond); |
266 | 267 |
267 // Methods used to indicate which source code is generated for. Source | 268 // Methods used to indicate which source code is generated for. Source |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 friend class FullCodeGenerator; | 313 friend class FullCodeGenerator; |
313 friend class FullCodeGenSyntaxChecker; | 314 friend class FullCodeGenSyntaxChecker; |
314 | 315 |
315 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 316 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
316 }; | 317 }; |
317 | 318 |
318 | 319 |
319 } } // namespace v8::internal | 320 } } // namespace v8::internal |
320 | 321 |
321 #endif // V8_MIPS_CODEGEN_MIPS_H_ | 322 #endif // V8_MIPS_CODEGEN_MIPS_H_ |
OLD | NEW |