18b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch// Copyright 2011 the V8 project authors. All rights reserved.
2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without
3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met:
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions of source code must retain the above copyright
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       notice, this list of conditions and the following disclaimer.
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions in binary form must reproduce the above
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       copyright notice, this list of conditions and the following
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       disclaimer in the documentation and/or other materials provided
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       with the distribution.
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Neither the name of Google Inc. nor the names of its
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       contributors may be used to endorse or promote products derived
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       from this software without specific prior written permission.
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_CODEGEN_H_
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_CODEGEN_H_
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "code-stubs.h"
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "runtime.h"
336ded16be15dd865a9b21ea304d5273c8be299c87Steve Block#include "type-info.h"
34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Include the declaration of the architecture defined class CodeGenerator.
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// The contract  to the shared code is that the the CodeGenerator is a subclass
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// of Visitor and that the following methods are available publicly:
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   MakeCode
393ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block//   MakeCodePrologue
403ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block//   MakeCodeEpilogue
41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   masm
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   frame
43d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block//   script
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   has_valid_frame
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   SetFrame
46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   DeleteFrame
47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   allocator
48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   AddDeferred
49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   in_spilled_code
50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   set_in_spilled_code
513ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block//   RecordPositions
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// These methods are either used privately by the shared code or implemented as
54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// shared code:
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   CodeGenerator
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   ~CodeGenerator
574515c472dc3e5ed2448a564600976759e569a0a8Leon Clarke//   Generate
583ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block//   ComputeLazyCompile
596ded16be15dd865a9b21ea304d5273c8be299c87Steve Block//   BuildFunctionInfo
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   ProcessDeclarations
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   DeclareGlobals
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   CheckForInlineRuntimeCall
633ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block//   AnalyzeCondition
64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   CodeForFunctionPosition
65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   CodeForReturnPosition
66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   CodeForStatementPosition
67d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block//   CodeForDoWhileConditionPosition
68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   CodeForSourcePosition
69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
70b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdochenum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
71b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
72bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#if V8_TARGET_ARCH_IA32
73bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#include "ia32/codegen-ia32.h"
74bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#elif V8_TARGET_ARCH_X64
75bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#include "x64/codegen-x64.h"
76bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#elif V8_TARGET_ARCH_ARM
77bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#include "arm/codegen-arm.h"
78bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#elif V8_TARGET_ARCH_MIPS
79bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#include "mips/codegen-mips.h"
80bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#else
81bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#error Unsupported target architecture.
82bb769b257e753aafcbd96767abb2abc645eaa20cBen Murdoch#endif
836ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochnamespace v8 {
853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochnamespace internal {
863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// Results of the library implementation of transcendental functions may differ
883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// from the one we use in our generated code.  Therefore we use the same
893ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// generated code both in runtime and compiled code.
903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochtypedef double (*UnaryMathFunction)(double x);
913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
923ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochUnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type);
933ef787dbeca8a5fb1086949cda830dccee07bfbdBen MurdochUnaryMathFunction CreateSqrtFunction();
943ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
953ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
963ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochclass ElementsTransitionGenerator : public AllStatic {
973ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch public:
983ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  static void GenerateSmiOnlyToObject(MacroAssembler* masm);
993ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  static void GenerateSmiOnlyToDouble(MacroAssembler* masm, Label* fail);
1003ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  static void GenerateDoubleToObject(MacroAssembler* masm, Label* fail);
1013ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
1023ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch private:
1033ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  DISALLOW_COPY_AND_ASSIGN(ElementsTransitionGenerator);
1043ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch};
1053ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
1063ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} }  // namespace v8::internal
1073ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch
108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_CODEGEN_H_
109