Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame^] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 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 | |
| 29 | #ifndef V8_MIPS_CODEGEN_MIPS_H_ |
| 30 | #define V8_MIPS_CODEGEN_MIPS_H_ |
| 31 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 32 | |
| 33 | #include "ast.h" |
| 34 | #include "code-stubs-mips.h" |
| 35 | #include "ic-inl.h" |
| 36 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 37 | namespace v8 { |
| 38 | namespace internal { |
| 39 | |
| 40 | // Forward declarations |
| 41 | class CompilationInfo; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 42 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 43 | enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 44 | |
| 45 | // ------------------------------------------------------------------------- |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 46 | // CodeGenerator |
| 47 | |
| 48 | class CodeGenerator: public AstVisitor { |
| 49 | public: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 50 | static bool MakeCode(CompilationInfo* info); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 51 | |
| 52 | // Printing of AST, etc. as requested by flags. |
| 53 | static void MakeCodePrologue(CompilationInfo* info); |
| 54 | |
| 55 | // Allocate and install the code. |
| 56 | static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm, |
| 57 | Code::Flags flags, |
| 58 | CompilationInfo* info); |
| 59 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 60 | // Print the code after compiling it. |
| 61 | static void PrintCode(Handle<Code> code, CompilationInfo* info); |
| 62 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 63 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 64 | static bool ShouldGenerateLog(Expression* type); |
| 65 | #endif |
| 66 | |
| 67 | static void SetFunctionInfo(Handle<JSFunction> fun, |
| 68 | FunctionLiteral* lit, |
| 69 | bool is_toplevel, |
| 70 | Handle<Script> script); |
| 71 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 72 | static bool RecordPositions(MacroAssembler* masm, |
| 73 | int pos, |
| 74 | bool right_here = false); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 75 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 76 | // Constants related to patching of inlined load/store. |
| 77 | static int GetInlinedKeyedLoadInstructionsAfterPatch() { |
| 78 | // This is in correlation with the padding in MacroAssembler::Abort. |
| 79 | return FLAG_debug_code ? 45 : 20; |
| 80 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame^] | 81 | |
| 82 | static const int kInlinedKeyedStoreInstructionsAfterPatch = 13; |
| 83 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 84 | static int GetInlinedNamedStoreInstructionsAfterPatch() { |
| 85 | ASSERT(Isolate::Current()->inlined_write_barrier_size() != -1); |
| 86 | // Magic number 5: instruction count after patched map load: |
| 87 | // li: 2 (liu & ori), Branch : 2 (bne & nop), sw : 1 |
| 88 | return Isolate::Current()->inlined_write_barrier_size() + 5; |
| 89 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 90 | |
| 91 | private: |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 92 | DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 93 | }; |
| 94 | |
| 95 | |
| 96 | } } // namespace v8::internal |
| 97 | |
| 98 | #endif // V8_MIPS_CODEGEN_MIPS_H_ |