• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "src/objects-inl.h"
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     CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
22     OFStream os(trace_scope.file());
23     code->Disassemble(name, os);
24   }
25 #endif
26   return code;
27 }
28 
29 
GetCodeWithFlags(Code::Flags flags,Handle<Name> name)30 Handle<Code> PropertyAccessCompiler::GetCodeWithFlags(Code::Flags flags,
31                                                       Handle<Name> name) {
32   return (FLAG_print_code_stubs && !name.is_null() && name->IsString())
33              ? GetCodeWithFlags(flags,
34                                 Handle<String>::cast(name)->ToCString().get())
35              : GetCodeWithFlags(flags, NULL);
36 }
37 
38 
TailCallBuiltin(MacroAssembler * masm,Builtins::Name name)39 void PropertyAccessCompiler::TailCallBuiltin(MacroAssembler* masm,
40                                              Builtins::Name name) {
41   Handle<Code> code(masm->isolate()->builtins()->builtin(name));
42   GenerateTailCall(masm, code);
43 }
44 
GetCallingConvention(Isolate * isolate,Code::Kind kind)45 Register* PropertyAccessCompiler::GetCallingConvention(Isolate* isolate,
46                                                        Code::Kind kind) {
47   AccessCompilerData* data = isolate->access_compiler_data();
48   if (!data->IsInitialized()) {
49     InitializePlatformSpecific(data);
50   }
51   if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC) {
52     return data->load_calling_convention();
53   }
54   DCHECK(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
55   return data->store_calling_convention();
56 }
57 
58 
slot() const59 Register PropertyAccessCompiler::slot() const {
60   if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
61     return LoadDescriptor::SlotRegister();
62   }
63   DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC);
64   return StoreWithVectorDescriptor::SlotRegister();
65 }
66 
67 
vector() const68 Register PropertyAccessCompiler::vector() const {
69   if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
70     return LoadWithVectorDescriptor::VectorRegister();
71   }
72   DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC);
73   return StoreWithVectorDescriptor::VectorRegister();
74 }
75 }  // namespace internal
76 }  // namespace v8
77