Line data Source code
1 : // Copyright 2014 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_IC_ACCESS_COMPILER_H_
6 : #define V8_IC_ACCESS_COMPILER_H_
7 :
8 : #include "src/code-stubs.h"
9 : #include "src/ic/access-compiler-data.h"
10 : #include "src/macro-assembler.h"
11 : #include "src/objects.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 : class PropertyAccessCompiler BASE_EMBEDDED {
17 : public:
18 38670 : static Builtins::Name MissBuiltin(Code::Kind kind) {
19 38670 : switch (kind) {
20 : case Code::LOAD_IC:
21 : return Builtins::kLoadIC_Miss;
22 : case Code::STORE_IC:
23 38393 : return Builtins::kStoreIC_Miss;
24 : case Code::KEYED_LOAD_IC:
25 0 : return Builtins::kKeyedLoadIC_Miss;
26 : case Code::KEYED_STORE_IC:
27 0 : return Builtins::kKeyedStoreIC_Miss;
28 : default:
29 0 : UNREACHABLE();
30 : }
31 : return Builtins::kLoadIC_Miss;
32 : }
33 :
34 : static void TailCallBuiltin(MacroAssembler* masm, Builtins::Name name);
35 :
36 : protected:
37 38698 : PropertyAccessCompiler(Isolate* isolate, Code::Kind kind)
38 38698 : : registers_(GetCallingConvention(isolate, kind)),
39 : kind_(kind),
40 : isolate_(isolate),
41 38698 : masm_(isolate, NULL, 256, CodeObjectRequired::kYes) {
42 : // TODO(yangguo): remove this once we can serialize IC stubs.
43 : masm_.enable_serializer();
44 38698 : }
45 :
46 : Code::Kind kind() const { return kind_; }
47 : MacroAssembler* masm() { return &masm_; }
48 : Isolate* isolate() const { return isolate_; }
49 38698 : Factory* factory() const { return isolate()->factory(); }
50 :
51 77396 : Register receiver() const { return registers_[0]; }
52 76814 : Register name() const { return registers_[1]; }
53 : Register slot() const;
54 : Register vector() const;
55 79354 : Register scratch1() const { return registers_[2]; }
56 57191 : Register scratch2() const { return registers_[3]; }
57 :
58 : Register* registers_;
59 :
60 : static void GenerateTailCall(MacroAssembler* masm, Handle<Code> code);
61 :
62 : private:
63 : static Register* GetCallingConvention(Isolate* isolate, Code::Kind kind);
64 : static void InitializePlatformSpecific(AccessCompilerData* data);
65 :
66 : Code::Kind kind_;
67 : Isolate* isolate_;
68 : MacroAssembler masm_;
69 : // Ensure that MacroAssembler has a reasonable size.
70 : STATIC_ASSERT(sizeof(MacroAssembler) < 128 * kPointerSize);
71 : };
72 : } // namespace internal
73 : } // namespace v8
74 :
75 : #endif // V8_IC_ACCESS_COMPILER_H_
|