blob: 01aa8052e1bc2eb90edee6815865f579811cf6ab [file] [log] [blame]
karlklose@chromium.org44bc7082011-04-11 12:33:05 +00001// Copyright 2011 the V8 project authors. All rights reserved.
ager@chromium.org7c537e22008-10-16 08:43:32 +00002// 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
ager@chromium.org5ec48922009-05-05 07:25:34 +000028#ifndef V8_ARM_CODEGEN_ARM_H_
29#define V8_ARM_CODEGEN_ARM_H_
ager@chromium.org7c537e22008-10-16 08:43:32 +000030
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000031#include "ast.h"
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000032#include "code-stubs-arm.h"
33#include "ic-inl.h"
ager@chromium.org357bf652010-04-12 11:30:10 +000034
kasperl@chromium.org71affb52009-05-26 05:44:31 +000035namespace v8 {
36namespace internal {
ager@chromium.org7c537e22008-10-16 08:43:32 +000037
38// Forward declarations
sgjesse@chromium.orgb302e562010-02-03 11:26:59 +000039class CompilationInfo;
ager@chromium.org7c537e22008-10-16 08:43:32 +000040
ager@chromium.org3bf7b912008-11-17 09:09:45 +000041enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
fschneider@chromium.org013f3e12010-04-26 13:27:52 +000042
fschneider@chromium.org013f3e12010-04-26 13:27:52 +000043// -------------------------------------------------------------------------
ager@chromium.org7c537e22008-10-16 08:43:32 +000044// CodeGenerator
45
ager@chromium.orga74f0da2008-12-03 16:05:52 +000046class CodeGenerator: public AstVisitor {
ager@chromium.org7c537e22008-10-16 08:43:32 +000047 public:
ager@chromium.orgb61a0d12010-10-13 08:35:23 +000048 static bool MakeCode(CompilationInfo* info);
ager@chromium.org7c537e22008-10-16 08:43:32 +000049
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000050 // Printing of AST, etc. as requested by flags.
ager@chromium.org5c838252010-02-19 08:53:10 +000051 static void MakeCodePrologue(CompilationInfo* info);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000052
53 // Allocate and install the code.
ager@chromium.org5c838252010-02-19 08:53:10 +000054 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000055 Code::Flags flags,
ager@chromium.org5c838252010-02-19 08:53:10 +000056 CompilationInfo* info);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000057
kasperl@chromium.orga5551262010-12-07 12:49:48 +000058 // Print the code after compiling it.
59 static void PrintCode(Handle<Code> code, CompilationInfo* info);
60
christian.plesner.hansen@gmail.comaca49682009-01-07 14:29:04 +000061#ifdef ENABLE_LOGGING_AND_PROFILING
christian.plesner.hansen@gmail.com37abdec2009-01-06 14:43:28 +000062 static bool ShouldGenerateLog(Expression* type);
christian.plesner.hansen@gmail.comaca49682009-01-07 14:29:04 +000063#endif
christian.plesner.hansen@gmail.com37abdec2009-01-06 14:43:28 +000064
ager@chromium.org7c537e22008-10-16 08:43:32 +000065 static void SetFunctionInfo(Handle<JSFunction> fun,
sgjesse@chromium.org911335c2009-08-19 12:59:44 +000066 FunctionLiteral* lit,
ager@chromium.org7c537e22008-10-16 08:43:32 +000067 bool is_toplevel,
sgjesse@chromium.org911335c2009-08-19 12:59:44 +000068 Handle<Script> script);
ager@chromium.org7c537e22008-10-16 08:43:32 +000069
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000070 static bool RecordPositions(MacroAssembler* masm,
71 int pos,
72 bool right_here = false);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000073
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000074 // Constants related to patching of inlined load/store.
fschneider@chromium.org40b9da32010-06-28 11:29:21 +000075 static int GetInlinedKeyedLoadInstructionsAfterPatch() {
ricow@chromium.org0b9f8502010-08-18 07:45:01 +000076 return FLAG_debug_code ? 32 : 13;
fschneider@chromium.org40b9da32010-06-28 11:29:21 +000077 }
ricow@chromium.orgbadaffc2011-03-17 12:15:27 +000078 static const int kInlinedKeyedStoreInstructionsAfterPatch = 8;
whesse@chromium.orgba5a61b2010-07-26 11:44:40 +000079 static int GetInlinedNamedStoreInstructionsAfterPatch() {
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000080 ASSERT(Isolate::Current()->inlined_write_barrier_size() != -1);
81 return Isolate::Current()->inlined_write_barrier_size() + 4;
whesse@chromium.orgba5a61b2010-07-26 11:44:40 +000082 }
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000083
ager@chromium.org7c537e22008-10-16 08:43:32 +000084 private:
ager@chromium.org7c537e22008-10-16 08:43:32 +000085 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
86};
87
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000088
ager@chromium.org7c537e22008-10-16 08:43:32 +000089} } // namespace v8::internal
90
ager@chromium.org5ec48922009-05-05 07:25:34 +000091#endif // V8_ARM_CODEGEN_ARM_H_