macro-assembler.h revision 80d68eab642096c1a48b6474d6ec33064b0ad1f5
1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2006-2008 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_MACRO_ASSEMBLER_H_
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_MACRO_ASSEMBLER_H_
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Helper types to make boolean flag easier to read at call-site.
33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum InvokeFlag {
34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  CALL_FUNCTION,
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  JUMP_FUNCTION
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum CodeLocation {
40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  IN_JAVASCRIPT,
41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  IN_JS_ENTRY,
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  IN_C_ENTRY
43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum HandlerType {
47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  TRY_CATCH_HANDLER,
48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  TRY_FINALLY_HANDLER,
49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  JS_ENTRY_HANDLER
50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
53402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// Invalid depth in prototype chain.
54402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescuconst int kInvalidProtoDepth = -1;
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#if V8_TARGET_ARCH_IA32
57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "assembler.h"
58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "ia32/assembler-ia32.h"
59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "ia32/assembler-ia32-inl.h"
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "code.h"  // must be after assembler_*.h
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "ia32/macro-assembler-ia32.h"
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#elif V8_TARGET_ARCH_X64
63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "assembler.h"
64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "x64/assembler-x64.h"
65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "x64/assembler-x64-inl.h"
66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "code.h"  // must be after assembler_*.h
67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "x64/macro-assembler-x64.h"
68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#elif V8_TARGET_ARCH_ARM
69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "arm/constants-arm.h"
70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "assembler.h"
71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "arm/assembler-arm.h"
72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "arm/assembler-arm-inl.h"
73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "code.h"  // must be after assembler_*.h
74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "arm/macro-assembler-arm.h"
753100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#elif V8_TARGET_ARCH_MIPS
763100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#include "mips/constants-mips.h"
773100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#include "assembler.h"
783100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#include "mips/assembler-mips.h"
793100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#include "mips/assembler-mips-inl.h"
803100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#include "code.h"  // must be after assembler_*.h
813100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#include "mips/macro-assembler-mips.h"
82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#else
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#error Unsupported target architecture.
84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
8680d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsennamespace v8 {
8780d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsennamespace internal {
8880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
8980d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen// Support for "structured" code comments.
9080d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen#ifdef DEBUG
9180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
9280d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsenclass Comment {
9380d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen public:
9480d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen  Comment(MacroAssembler* masm, const char* msg);
9580d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen  ~Comment();
9680d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
9780d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen private:
9880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen  MacroAssembler* masm_;
9980d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen  const char* msg_;
10080d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen};
10180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
10280d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen#else
10380d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
10480d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsenclass Comment {
10580d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen public:
10680d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen  Comment(MacroAssembler*, const char*)  {}
10780d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen};
10880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
10980d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen#endif  // DEBUG
11080d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
11180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen} }  // namespace v8::internal
11280d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen
113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_MACRO_ASSEMBLER_H_
114