blob: 6de472500e694da76c6d8d247b90f83e6799e817 [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_IA32_CODEGEN_IA32_H_
29#define V8_IA32_CODEGEN_IA32_H_
ager@chromium.org7c537e22008-10-16 08:43:32 +000030
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000031#include "ast.h"
ager@chromium.orgce5e87b2010-03-10 10:24:18 +000032#include "ic-inl.h"
33
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
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +000040static const int kSizeOfFullCodegenStrictModePrologue = 34;
41static const int kSizeOfOptimizedStrictModePrologue = 12;
42static const int kSizeOfOptimizedAlignStackPrologue = 44;
43
ager@chromium.org7c537e22008-10-16 08:43:32 +000044// -------------------------------------------------------------------------
45// CodeGenerator
46
karlklose@chromium.org44bc7082011-04-11 12:33:05 +000047class CodeGenerator {
ager@chromium.org7c537e22008-10-16 08:43:32 +000048 public:
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000049 // Printing of AST, etc. as requested by flags.
ager@chromium.org5c838252010-02-19 08:53:10 +000050 static void MakeCodePrologue(CompilationInfo* info);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000051
52 // Allocate and install the code.
ager@chromium.org5c838252010-02-19 08:53:10 +000053 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000054 Code::Flags flags,
ager@chromium.org5c838252010-02-19 08:53:10 +000055 CompilationInfo* info);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000056
kasperl@chromium.orga5551262010-12-07 12:49:48 +000057 // Print the code after compiling it.
58 static void PrintCode(Handle<Code> code, CompilationInfo* info);
59
christian.plesner.hansen@gmail.com37abdec2009-01-06 14:43:28 +000060 static bool ShouldGenerateLog(Expression* type);
61
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000062 static bool RecordPositions(MacroAssembler* masm,
63 int pos,
64 bool right_here = false);
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +000065
ager@chromium.org7c537e22008-10-16 08:43:32 +000066
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000067 static Operand FixedArrayElementOperand(Register array,
68 Register index_as_smi,
69 int additional_offset = 0) {
70 int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize;
71 return FieldOperand(array, index_as_smi, times_half_pointer_size, offset);
72 }
73
ager@chromium.org7c537e22008-10-16 08:43:32 +000074 private:
ager@chromium.org7c537e22008-10-16 08:43:32 +000075 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
76};
77
78
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +000079class StringCharLoadGenerator : public AllStatic {
80 public:
81 // Generates the code for handling different string types and loading the
82 // indexed character into |result|. We expect |index| as untagged input and
83 // |result| as untagged output.
84 static void Generate(MacroAssembler* masm,
85 Factory* factory,
86 Register string,
87 Register index,
88 Register result,
89 Label* call_runtime);
90
91 private:
92 DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator);
93};
94
danno@chromium.org1f34ad32012-11-26 14:53:56 +000095
96class MathExpGenerator : public AllStatic {
97 public:
98 static void EmitMathExp(MacroAssembler* masm,
99 XMMRegister input,
100 XMMRegister result,
101 XMMRegister double_scratch,
102 Register temp1,
103 Register temp2);
104
105 private:
106 DISALLOW_COPY_AND_ASSIGN(MathExpGenerator);
107};
108
ager@chromium.org7c537e22008-10-16 08:43:32 +0000109} } // namespace v8::internal
110
ager@chromium.org5ec48922009-05-05 07:25:34 +0000111#endif // V8_IA32_CODEGEN_IA32_H_