Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/ic/ic-compiler.h

Issue 480413008: Move PropertyAccessCompiler and CallOptimization to their own files (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ic/ic.cc ('k') | src/ic/ic-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_IC_IC_COMPILER_H_ 5 #ifndef V8_IC_IC_COMPILER_H_
6 #define V8_IC_IC_COMPILER_H_ 6 #define V8_IC_IC_COMPILER_H_
7 7
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/ic/access-compiler.h"
9 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
10 #include "src/objects.h" 11 #include "src/objects.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 15
15 16
16 class CallOptimization; 17 class CallOptimization;
17 class SmallMapList;
18 class StubCache;
19 18
20 19
21 enum PrototypeCheckType { CHECK_ALL_MAPS, SKIP_RECEIVER }; 20 enum PrototypeCheckType { CHECK_ALL_MAPS, SKIP_RECEIVER };
22 enum IcCheckType { ELEMENT, PROPERTY }; 21 enum IcCheckType { ELEMENT, PROPERTY };
23 22
24 23
25 class PropertyAccessCompiler BASE_EMBEDDED {
26 public:
27 static Builtins::Name MissBuiltin(Code::Kind kind) {
28 switch (kind) {
29 case Code::LOAD_IC:
30 return Builtins::kLoadIC_Miss;
31 case Code::STORE_IC:
32 return Builtins::kStoreIC_Miss;
33 case Code::KEYED_LOAD_IC:
34 return Builtins::kKeyedLoadIC_Miss;
35 case Code::KEYED_STORE_IC:
36 return Builtins::kKeyedStoreIC_Miss;
37 default:
38 UNREACHABLE();
39 }
40 return Builtins::kLoadIC_Miss;
41 }
42
43 static void TailCallBuiltin(MacroAssembler* masm, Builtins::Name name);
44
45 protected:
46 PropertyAccessCompiler(Isolate* isolate, Code::Kind kind,
47 CacheHolderFlag cache_holder)
48 : registers_(GetCallingConvention(kind)),
49 kind_(kind),
50 cache_holder_(cache_holder),
51 isolate_(isolate),
52 masm_(isolate, NULL, 256) {}
53
54 Code::Kind kind() const { return kind_; }
55 CacheHolderFlag cache_holder() const { return cache_holder_; }
56 MacroAssembler* masm() { return &masm_; }
57 Isolate* isolate() const { return isolate_; }
58 Heap* heap() const { return isolate()->heap(); }
59 Factory* factory() const { return isolate()->factory(); }
60
61 Register receiver() const { return registers_[0]; }
62 Register name() const { return registers_[1]; }
63 Register scratch1() const { return registers_[2]; }
64 Register scratch2() const { return registers_[3]; }
65 Register scratch3() const { return registers_[4]; }
66
67 // Calling convention between indexed store IC and handler.
68 Register transition_map() const { return scratch1(); }
69
70 static Register* GetCallingConvention(Code::Kind);
71 static Register* load_calling_convention();
72 static Register* store_calling_convention();
73 static Register* keyed_store_calling_convention();
74
75 Register* registers_;
76
77 static void GenerateTailCall(MacroAssembler* masm, Handle<Code> code);
78
79 Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name);
80 Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<Name> name);
81
82 private:
83 Code::Kind kind_;
84 CacheHolderFlag cache_holder_;
85
86 Isolate* isolate_;
87 MacroAssembler masm_;
88 };
89
90
91 class PropertyICCompiler : public PropertyAccessCompiler { 24 class PropertyICCompiler : public PropertyAccessCompiler {
92 public: 25 public:
93 // Finds the Code object stored in the Heap::non_monomorphic_cache(). 26 // Finds the Code object stored in the Heap::non_monomorphic_cache().
94 static Code* FindPreMonomorphic(Isolate* isolate, Code::Kind kind, 27 static Code* FindPreMonomorphic(Isolate* isolate, Code::Kind kind,
95 ExtraICState extra_ic_state); 28 ExtraICState extra_ic_state);
96 29
97 // Named 30 // Named
98 static Handle<Code> ComputeLoad(Isolate* isolate, InlineCacheState ic_state, 31 static Handle<Code> ComputeLoad(Isolate* isolate, InlineCacheState ic_state,
99 ExtraICState extra_state); 32 ExtraICState extra_state);
100 static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state, 33 static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 virtual ~ElementHandlerCompiler() {} 377 virtual ~ElementHandlerCompiler() {}
445 378
446 void CompileElementHandlers(MapHandleList* receiver_maps, 379 void CompileElementHandlers(MapHandleList* receiver_maps,
447 CodeHandleList* handlers); 380 CodeHandleList* handlers);
448 381
449 static void GenerateLoadDictionaryElement(MacroAssembler* masm); 382 static void GenerateLoadDictionaryElement(MacroAssembler* masm);
450 static void GenerateStoreDictionaryElement(MacroAssembler* masm); 383 static void GenerateStoreDictionaryElement(MacroAssembler* masm);
451 }; 384 };
452 385
453 386
454 // Holds information about possible function call optimizations.
455 class CallOptimization BASE_EMBEDDED {
456 public:
457 explicit CallOptimization(Handle<JSFunction> function);
458
459 bool is_constant_call() const { return !constant_function_.is_null(); }
460
461 Handle<JSFunction> constant_function() const {
462 DCHECK(is_constant_call());
463 return constant_function_;
464 }
465
466 bool is_simple_api_call() const { return is_simple_api_call_; }
467
468 Handle<FunctionTemplateInfo> expected_receiver_type() const {
469 DCHECK(is_simple_api_call());
470 return expected_receiver_type_;
471 }
472
473 Handle<CallHandlerInfo> api_call_info() const {
474 DCHECK(is_simple_api_call());
475 return api_call_info_;
476 }
477
478 enum HolderLookup { kHolderNotFound, kHolderIsReceiver, kHolderFound };
479 Handle<JSObject> LookupHolderOfExpectedType(
480 Handle<Map> receiver_map, HolderLookup* holder_lookup) const;
481
482 // Check if the api holder is between the receiver and the holder.
483 bool IsCompatibleReceiver(Handle<Object> receiver,
484 Handle<JSObject> holder) const;
485
486 private:
487 void Initialize(Handle<JSFunction> function);
488
489 // Determines whether the given function can be called using the
490 // fast api call builtin.
491 void AnalyzePossibleApiFunction(Handle<JSFunction> function);
492
493 Handle<JSFunction> constant_function_;
494 bool is_simple_api_call_;
495 Handle<FunctionTemplateInfo> expected_receiver_type_;
496 Handle<CallHandlerInfo> api_call_info_;
497 };
498 } 387 }
499 } // namespace v8::internal 388 } // namespace v8::internal
500 389
501 #endif // V8_IC_IC_COMPILER_H_ 390 #endif // V8_IC_IC_COMPILER_H_
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/ic/ic-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698