| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 private: | 157 private: |
| 158 // Construction/Destruction. | 158 // Construction/Destruction. |
| 159 explicit CodeGenerator(MacroAssembler* masm); | 159 explicit CodeGenerator(MacroAssembler* masm); |
| 160 virtual ~CodeGenerator() { delete masm_; } | |
| 161 | 160 |
| 162 // Accessors. | 161 // Accessors. |
| 163 inline bool is_eval(); | 162 inline bool is_eval(); |
| 164 Scope* scope() const { return scope_; } | 163 inline Scope* scope(); |
| 165 | 164 |
| 166 // Generating deferred code. | 165 // Generating deferred code. |
| 167 void ProcessDeferred(); | 166 void ProcessDeferred(); |
| 168 | 167 |
| 169 // State | 168 // State |
| 170 bool has_cc() const { return cc_reg_ != cc_always; } | 169 bool has_cc() const { return cc_reg_ != cc_always; } |
| 171 TypeofState typeof_state() const { return state_->typeof_state(); } | 170 TypeofState typeof_state() const { return state_->typeof_state(); } |
| 172 JumpTarget* true_target() const { return state_->true_target(); } | 171 JumpTarget* true_target() const { return state_->true_target(); } |
| 173 JumpTarget* false_target() const { return state_->false_target(); } | 172 JumpTarget* false_target() const { return state_->false_target(); } |
| 174 | 173 |
| 175 // We don't track loop nesting level on mips yet. | 174 // We don't track loop nesting level on mips yet. |
| 176 int loop_nesting() const { return 0; } | 175 int loop_nesting() const { return 0; } |
| 177 | 176 |
| 178 // Node visitors. | 177 // Node visitors. |
| 179 void VisitStatements(ZoneList<Statement*>* statements); | 178 void VisitStatements(ZoneList<Statement*>* statements); |
| 180 | 179 |
| 181 #define DEF_VISIT(type) \ | 180 #define DEF_VISIT(type) \ |
| 182 void Visit##type(type* node); | 181 void Visit##type(type* node); |
| 183 AST_NODE_LIST(DEF_VISIT) | 182 AST_NODE_LIST(DEF_VISIT) |
| 184 #undef DEF_VISIT | 183 #undef DEF_VISIT |
| 185 | 184 |
| 186 // Main code generation function | 185 // Main code generation function |
| 187 void Generate(CompilationInfo* info, Mode mode); | 186 void Generate(CompilationInfo* info); |
| 188 | 187 |
| 189 struct InlineRuntimeLUT { | 188 struct InlineRuntimeLUT { |
| 190 void (CodeGenerator::*method)(ZoneList<Expression*>*); | 189 void (CodeGenerator::*method)(ZoneList<Expression*>*); |
| 191 const char* name; | 190 const char* name; |
| 192 }; | 191 }; |
| 193 | 192 |
| 194 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name); | 193 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name); |
| 195 bool CheckForInlineRuntimeCall(CallRuntime* node); | 194 bool CheckForInlineRuntimeCall(CallRuntime* node); |
| 196 static bool PatchInlineRuntimeEntry(Handle<String> name, | 195 static bool PatchInlineRuntimeEntry(Handle<String> name, |
| 197 const InlineRuntimeLUT& new_entry, | 196 const InlineRuntimeLUT& new_entry, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 220 void GenerateArgumentsAccess(ZoneList<Expression*>* args); | 219 void GenerateArgumentsAccess(ZoneList<Expression*>* args); |
| 221 | 220 |
| 222 // Support for accessing the class and value fields of an object. | 221 // Support for accessing the class and value fields of an object. |
| 223 void GenerateClassOf(ZoneList<Expression*>* args); | 222 void GenerateClassOf(ZoneList<Expression*>* args); |
| 224 void GenerateValueOf(ZoneList<Expression*>* args); | 223 void GenerateValueOf(ZoneList<Expression*>* args); |
| 225 void GenerateSetValueOf(ZoneList<Expression*>* args); | 224 void GenerateSetValueOf(ZoneList<Expression*>* args); |
| 226 | 225 |
| 227 // Fast support for charCodeAt(n). | 226 // Fast support for charCodeAt(n). |
| 228 void GenerateFastCharCodeAt(ZoneList<Expression*>* args); | 227 void GenerateFastCharCodeAt(ZoneList<Expression*>* args); |
| 229 | 228 |
| 229 // Fast support for string.charAt(n) and string[n]. |
| 230 void GenerateCharFromCode(ZoneList<Expression*>* args); |
| 231 |
| 230 // Fast support for object equality testing. | 232 // Fast support for object equality testing. |
| 231 void GenerateObjectEquals(ZoneList<Expression*>* args); | 233 void GenerateObjectEquals(ZoneList<Expression*>* args); |
| 232 | 234 |
| 233 void GenerateLog(ZoneList<Expression*>* args); | 235 void GenerateLog(ZoneList<Expression*>* args); |
| 234 | 236 |
| 235 // Fast support for Math.random(). | 237 // Fast support for Math.random(). |
| 236 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); | 238 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); |
| 237 | 239 |
| 238 void GenerateIsObject(ZoneList<Expression*>* args); | 240 void GenerateIsObject(ZoneList<Expression*>* args); |
| 239 void GenerateIsFunction(ZoneList<Expression*>* args); | 241 void GenerateIsFunction(ZoneList<Expression*>* args); |
| 240 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); | 242 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); |
| 241 void GenerateStringAdd(ZoneList<Expression*>* args); | 243 void GenerateStringAdd(ZoneList<Expression*>* args); |
| 242 void GenerateSubString(ZoneList<Expression*>* args); | 244 void GenerateSubString(ZoneList<Expression*>* args); |
| 243 void GenerateStringCompare(ZoneList<Expression*>* args); | 245 void GenerateStringCompare(ZoneList<Expression*>* args); |
| 244 void GenerateRegExpExec(ZoneList<Expression*>* args); | 246 void GenerateRegExpExec(ZoneList<Expression*>* args); |
| 245 void GenerateNumberToString(ZoneList<Expression*>* args); | 247 void GenerateNumberToString(ZoneList<Expression*>* args); |
| 246 | 248 |
| 249 // Fast support for Math.pow(). |
| 250 void GenerateMathPow(ZoneList<Expression*>* args); |
| 251 // Fast support for Math.sqrt(). |
| 252 void GenerateMathPow(ZoneList<Expression*>* args); |
| 253 |
| 247 | 254 |
| 248 // Fast support for Math.sin and Math.cos. | 255 // Fast support for Math.sin and Math.cos. |
| 249 inline void GenerateMathSin(ZoneList<Expression*>* args); | 256 inline void GenerateMathSin(ZoneList<Expression*>* args); |
| 250 inline void GenerateMathCos(ZoneList<Expression*>* args); | 257 inline void GenerateMathCos(ZoneList<Expression*>* args); |
| 251 | 258 |
| 252 // Simple condition analysis. | 259 // Simple condition analysis. |
| 253 enum ConditionAnalysis { | 260 enum ConditionAnalysis { |
| 254 ALWAYS_TRUE, | 261 ALWAYS_TRUE, |
| 255 ALWAYS_FALSE, | 262 ALWAYS_FALSE, |
| 256 DONT_KNOW | 263 DONT_KNOW |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // function_return_ does not jump to the true function return, but rather | 302 // function_return_ does not jump to the true function return, but rather |
| 296 // to some unlinking code). | 303 // to some unlinking code). |
| 297 bool function_return_is_shadowed_; | 304 bool function_return_is_shadowed_; |
| 298 | 305 |
| 299 static InlineRuntimeLUT kInlineRuntimeLUT[]; | 306 static InlineRuntimeLUT kInlineRuntimeLUT[]; |
| 300 | 307 |
| 301 friend class VirtualFrame; | 308 friend class VirtualFrame; |
| 302 friend class JumpTarget; | 309 friend class JumpTarget; |
| 303 friend class Reference; | 310 friend class Reference; |
| 304 friend class FastCodeGenerator; | 311 friend class FastCodeGenerator; |
| 312 friend class FullCodeGenerator; |
| 305 friend class FullCodeGenSyntaxChecker; | 313 friend class FullCodeGenSyntaxChecker; |
| 306 | 314 |
| 307 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 315 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 308 }; | 316 }; |
| 309 | 317 |
| 310 | 318 |
| 311 } } // namespace v8::internal | 319 } } // namespace v8::internal |
| 312 | 320 |
| 313 #endif // V8_MIPS_CODEGEN_MIPS_H_ | 321 #endif // V8_MIPS_CODEGEN_MIPS_H_ |
| OLD | NEW |