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

Side by Side Diff: src/type-info.cc

Issue 641373002: Introduce FeedbackVectorSlot type - better than int. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ports. Created 6 years, 2 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/type-info.h ('k') | src/utils.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/ic/ic.h" 10 #include "src/ic/ic.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 Cell* cell = Cell::cast(value); 42 Cell* cell = Cell::cast(value);
43 return Handle<Object>(cell->value(), isolate()); 43 return Handle<Object>(cell->value(), isolate());
44 } else { 44 } else {
45 return Handle<Object>(value, isolate()); 45 return Handle<Object>(value, isolate());
46 } 46 }
47 } 47 }
48 return Handle<Object>::cast(isolate()->factory()->undefined_value()); 48 return Handle<Object>::cast(isolate()->factory()->undefined_value());
49 } 49 }
50 50
51 51
52 Handle<Object> TypeFeedbackOracle::GetInfo(int slot) { 52 Handle<Object> TypeFeedbackOracle::GetInfo(FeedbackVectorSlot slot) {
53 DCHECK(slot >= 0 && slot < feedback_vector_->length()); 53 DCHECK(slot.ToInt() >= 0 && slot.ToInt() < feedback_vector_->length());
54 Object* obj = feedback_vector_->get(slot); 54 Object* obj = feedback_vector_->get(slot.ToInt());
55 if (!obj->IsJSFunction() || 55 if (!obj->IsJSFunction() ||
56 !CanRetainOtherContext(JSFunction::cast(obj), *native_context_)) { 56 !CanRetainOtherContext(JSFunction::cast(obj), *native_context_)) {
57 return Handle<Object>(obj, isolate()); 57 return Handle<Object>(obj, isolate());
58 } 58 }
59 return Handle<Object>::cast(isolate()->factory()->undefined_value()); 59 return Handle<Object>::cast(isolate()->factory()->undefined_value());
60 } 60 }
61 61
62 62
63 bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) { 63 bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) {
64 Handle<Object> maybe_code = GetInfo(id); 64 Handle<Object> maybe_code = GetInfo(id);
65 if (maybe_code->IsCode()) { 65 if (maybe_code->IsCode()) {
66 Handle<Code> code = Handle<Code>::cast(maybe_code); 66 Handle<Code> code = Handle<Code>::cast(maybe_code);
67 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED; 67 return code->is_inline_cache_stub() && code->ic_state() == UNINITIALIZED;
68 } 68 }
69 return false; 69 return false;
70 } 70 }
71 71
72 72
73 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) { 73 bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) {
74 Handle<Object> maybe_code = GetInfo(ast_id); 74 Handle<Object> maybe_code = GetInfo(ast_id);
75 if (!maybe_code->IsCode()) return false; 75 if (!maybe_code->IsCode()) return false;
76 Handle<Code> code = Handle<Code>::cast(maybe_code); 76 Handle<Code> code = Handle<Code>::cast(maybe_code);
77 return code->ic_state() == UNINITIALIZED; 77 return code->ic_state() == UNINITIALIZED;
78 } 78 }
79 79
80 80
81 bool TypeFeedbackOracle::CallIsMonomorphic(int slot) { 81 bool TypeFeedbackOracle::CallIsMonomorphic(FeedbackVectorSlot slot) {
82 Handle<Object> value = GetInfo(slot); 82 Handle<Object> value = GetInfo(slot);
83 return value->IsAllocationSite() || value->IsJSFunction(); 83 return value->IsAllocationSite() || value->IsJSFunction();
84 } 84 }
85 85
86 86
87 bool TypeFeedbackOracle::CallNewIsMonomorphic(int slot) { 87 bool TypeFeedbackOracle::CallNewIsMonomorphic(FeedbackVectorSlot slot) {
88 Handle<Object> info = GetInfo(slot); 88 Handle<Object> info = GetInfo(slot);
89 return FLAG_pretenuring_call_new 89 return FLAG_pretenuring_call_new
90 ? info->IsJSFunction() 90 ? info->IsJSFunction()
91 : info->IsAllocationSite() || info->IsJSFunction(); 91 : info->IsAllocationSite() || info->IsJSFunction();
92 } 92 }
93 93
94 94
95 byte TypeFeedbackOracle::ForInType(int feedback_vector_slot) { 95 byte TypeFeedbackOracle::ForInType(FeedbackVectorSlot feedback_vector_slot) {
96 Handle<Object> value = GetInfo(feedback_vector_slot); 96 Handle<Object> value = GetInfo(feedback_vector_slot);
97 return value.is_identical_to( 97 return value.is_identical_to(
98 TypeFeedbackVector::UninitializedSentinel(isolate())) 98 TypeFeedbackVector::UninitializedSentinel(isolate()))
99 ? ForInStatement::FAST_FOR_IN 99 ? ForInStatement::FAST_FOR_IN
100 : ForInStatement::SLOW_FOR_IN; 100 : ForInStatement::SLOW_FOR_IN;
101 } 101 }
102 102
103 103
104 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( 104 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode(
105 TypeFeedbackId ast_id) { 105 TypeFeedbackId ast_id) {
106 Handle<Object> maybe_code = GetInfo(ast_id); 106 Handle<Object> maybe_code = GetInfo(ast_id);
107 if (maybe_code->IsCode()) { 107 if (maybe_code->IsCode()) {
108 Handle<Code> code = Handle<Code>::cast(maybe_code); 108 Handle<Code> code = Handle<Code>::cast(maybe_code);
109 if (code->kind() == Code::KEYED_STORE_IC) { 109 if (code->kind() == Code::KEYED_STORE_IC) {
110 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()); 110 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state());
111 } 111 }
112 } 112 }
113 return STANDARD_STORE; 113 return STANDARD_STORE;
114 } 114 }
115 115
116 116
117 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(int slot) { 117 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(FeedbackVectorSlot slot) {
118 Handle<Object> info = GetInfo(slot); 118 Handle<Object> info = GetInfo(slot);
119 if (info->IsAllocationSite()) { 119 if (info->IsAllocationSite()) {
120 return Handle<JSFunction>(isolate()->native_context()->array_function()); 120 return Handle<JSFunction>(isolate()->native_context()->array_function());
121 } 121 }
122 122
123 return Handle<JSFunction>::cast(info); 123 return Handle<JSFunction>::cast(info);
124 } 124 }
125 125
126 126
127 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(int slot) { 127 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(
128 FeedbackVectorSlot slot) {
128 Handle<Object> info = GetInfo(slot); 129 Handle<Object> info = GetInfo(slot);
129 if (FLAG_pretenuring_call_new || info->IsJSFunction()) { 130 if (FLAG_pretenuring_call_new || info->IsJSFunction()) {
130 return Handle<JSFunction>::cast(info); 131 return Handle<JSFunction>::cast(info);
131 } 132 }
132 133
133 DCHECK(info->IsAllocationSite()); 134 DCHECK(info->IsAllocationSite());
134 return Handle<JSFunction>(isolate()->native_context()->array_function()); 135 return Handle<JSFunction>(isolate()->native_context()->array_function());
135 } 136 }
136 137
137 138
138 Handle<AllocationSite> TypeFeedbackOracle::GetCallAllocationSite(int slot) { 139 Handle<AllocationSite> TypeFeedbackOracle::GetCallAllocationSite(
140 FeedbackVectorSlot slot) {
139 Handle<Object> info = GetInfo(slot); 141 Handle<Object> info = GetInfo(slot);
140 if (info->IsAllocationSite()) { 142 if (info->IsAllocationSite()) {
141 return Handle<AllocationSite>::cast(info); 143 return Handle<AllocationSite>::cast(info);
142 } 144 }
143 return Handle<AllocationSite>::null(); 145 return Handle<AllocationSite>::null();
144 } 146 }
145 147
146 148
147 Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite(int slot) { 149 Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite(
150 FeedbackVectorSlot slot) {
148 Handle<Object> info = GetInfo(slot); 151 Handle<Object> info = GetInfo(slot);
149 if (FLAG_pretenuring_call_new || info->IsAllocationSite()) { 152 if (FLAG_pretenuring_call_new || info->IsAllocationSite()) {
150 return Handle<AllocationSite>::cast(info); 153 return Handle<AllocationSite>::cast(info);
151 } 154 }
152 return Handle<AllocationSite>::null(); 155 return Handle<AllocationSite>::null();
153 } 156 }
154 157
155 158
156 bool TypeFeedbackOracle::LoadIsBuiltin( 159 bool TypeFeedbackOracle::LoadIsBuiltin(
157 TypeFeedbackId id, Builtins::Name builtin) { 160 TypeFeedbackId id, Builtins::Name builtin) {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 UnseededNumberDictionary::kNotFound); 450 UnseededNumberDictionary::kNotFound);
448 // Dictionary has been allocated with sufficient size for all elements. 451 // Dictionary has been allocated with sufficient size for all elements.
449 DisallowHeapAllocation no_need_to_resize_dictionary; 452 DisallowHeapAllocation no_need_to_resize_dictionary;
450 HandleScope scope(isolate()); 453 HandleScope scope(isolate());
451 USE(UnseededNumberDictionary::AtNumberPut( 454 USE(UnseededNumberDictionary::AtNumberPut(
452 dictionary_, IdToKey(ast_id), handle(target, isolate()))); 455 dictionary_, IdToKey(ast_id), handle(target, isolate())));
453 } 456 }
454 457
455 458
456 } } // namespace v8::internal 459 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698