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 #include "src/ic/access-compiler.h"
6
7
8 namespace v8 {
9 namespace internal {
10
11
GetCodeWithFlags(Code::Flags flags,const char * name)12 Handle<Code> PropertyAccessCompiler::GetCodeWithFlags(Code::Flags flags,
13 const char* name) {
14 // Create code object in the heap.
15 CodeDesc desc;
16 masm()->GetCode(&desc);
17 Handle<Code> code = factory()->NewCode(desc, flags, masm()->CodeObject());
18 if (code->IsCodeStubOrIC()) code->set_stub_key(CodeStub::NoCacheKey());
19 #ifdef ENABLE_DISASSEMBLER
20 if (FLAG_print_code_stubs) {
21 OFStream os(stdout);
22 code->Disassemble(name, os);
23 }
24 #endif
25 return code;
26 }
27
28
GetCodeWithFlags(Code::Flags flags,Handle<Name> name)29 Handle<Code> PropertyAccessCompiler::GetCodeWithFlags(Code::Flags flags,
30 Handle<Name> name) {
31 return (FLAG_print_code_stubs && !name.is_null() && name->IsString())
32 ? GetCodeWithFlags(flags,
33 Handle<String>::cast(name)->ToCString().get())
34 : GetCodeWithFlags(flags, NULL);
35 }
36
37
TailCallBuiltin(MacroAssembler * masm,Builtins::Name name)38 void PropertyAccessCompiler::TailCallBuiltin(MacroAssembler* masm,
39 Builtins::Name name) {
40 Handle<Code> code(masm->isolate()->builtins()->builtin(name));
41 GenerateTailCall(masm, code);
42 }
43
44
GetCallingConvention(Code::Kind kind)45 Register* PropertyAccessCompiler::GetCallingConvention(Code::Kind kind) {
46 if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC) {
47 return load_calling_convention();
48 }
49 DCHECK(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
50 return store_calling_convention();
51 }
52
53
slot() const54 Register PropertyAccessCompiler::slot() const {
55 if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
56 return LoadDescriptor::SlotRegister();
57 }
58 DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC);
59 return VectorStoreICDescriptor::SlotRegister();
60 }
61
62
vector() const63 Register PropertyAccessCompiler::vector() const {
64 if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
65 return LoadWithVectorDescriptor::VectorRegister();
66 }
67 DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC);
68 return VectorStoreICDescriptor::VectorRegister();
69 }
70 } // namespace internal
71 } // namespace v8
72