blob: 75899a948e7dcec3a56737a28a6c1f235463c0d0 [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 "ic-inl.h"
ager@chromium.org357bf652010-04-12 11:30:10 +000033
kasperl@chromium.org71affb52009-05-26 05:44:31 +000034namespace v8 {
35namespace internal {
ager@chromium.org7c537e22008-10-16 08:43:32 +000036
37// Forward declarations
sgjesse@chromium.orgb302e562010-02-03 11:26:59 +000038class CompilationInfo;
ager@chromium.org7c537e22008-10-16 08:43:32 +000039
ager@chromium.org3bf7b912008-11-17 09:09:45 +000040enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
fschneider@chromium.org013f3e12010-04-26 13:27:52 +000041
fschneider@chromium.org013f3e12010-04-26 13:27:52 +000042// -------------------------------------------------------------------------
ager@chromium.org7c537e22008-10-16 08:43:32 +000043// CodeGenerator
44
ager@chromium.orga74f0da2008-12-03 16:05:52 +000045class CodeGenerator: public AstVisitor {
ager@chromium.org7c537e22008-10-16 08:43:32 +000046 public:
mstarzinger@chromium.org32280cf2012-12-06 17:32:37 +000047 CodeGenerator() {
48 InitializeAstVisitor();
49 }
50
ager@chromium.orgb61a0d12010-10-13 08:35:23 +000051 static bool MakeCode(CompilationInfo* info);
ager@chromium.org7c537e22008-10-16 08:43:32 +000052
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000053 // Printing of AST, etc. as requested by flags.
ager@chromium.org5c838252010-02-19 08:53:10 +000054 static void MakeCodePrologue(CompilationInfo* info);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000055
56 // Allocate and install the code.
ager@chromium.org5c838252010-02-19 08:53:10 +000057 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000058 Code::Flags flags,
ager@chromium.org5c838252010-02-19 08:53:10 +000059 CompilationInfo* info);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000060
kasperl@chromium.orga5551262010-12-07 12:49:48 +000061 // Print the code after compiling it.
62 static void PrintCode(Handle<Code> code, CompilationInfo* info);
63
christian.plesner.hansen@gmail.com37abdec2009-01-06 14:43:28 +000064 static bool ShouldGenerateLog(Expression* type);
65
ager@chromium.org7c537e22008-10-16 08:43:32 +000066 static void SetFunctionInfo(Handle<JSFunction> fun,
sgjesse@chromium.org911335c2009-08-19 12:59:44 +000067 FunctionLiteral* lit,
ager@chromium.org7c537e22008-10-16 08:43:32 +000068 bool is_toplevel,
sgjesse@chromium.org911335c2009-08-19 12:59:44 +000069 Handle<Script> script);
ager@chromium.org7c537e22008-10-16 08:43:32 +000070
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000071 static bool RecordPositions(MacroAssembler* masm,
72 int pos,
73 bool right_here = false);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000074
mstarzinger@chromium.org32280cf2012-12-06 17:32:37 +000075 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
76
ager@chromium.org7c537e22008-10-16 08:43:32 +000077 private:
ager@chromium.org7c537e22008-10-16 08:43:32 +000078 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
79};
80
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000081
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +000082class StringCharLoadGenerator : public AllStatic {
83 public:
84 // Generates the code for handling different string types and loading the
85 // indexed character into |result|. We expect |index| as untagged input and
86 // |result| as untagged output.
87 static void Generate(MacroAssembler* masm,
88 Register string,
89 Register index,
90 Register result,
91 Label* call_runtime);
92
93 private:
94 DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator);
95};
96
danno@chromium.org1f34ad32012-11-26 14:53:56 +000097
98class MathExpGenerator : public AllStatic {
99 public:
100 static void EmitMathExp(MacroAssembler* masm,
mstarzinger@chromium.org32280cf2012-12-06 17:32:37 +0000101 DwVfpRegister input,
102 DwVfpRegister result,
103 DwVfpRegister double_scratch1,
104 DwVfpRegister double_scratch2,
danno@chromium.org1f34ad32012-11-26 14:53:56 +0000105 Register temp1,
106 Register temp2,
107 Register temp3);
108
109 private:
110 DISALLOW_COPY_AND_ASSIGN(MathExpGenerator);
111};
112
ager@chromium.org7c537e22008-10-16 08:43:32 +0000113} } // namespace v8::internal
114
ager@chromium.org5ec48922009-05-05 07:25:34 +0000115#endif // V8_ARM_CODEGEN_ARM_H_