OLD | NEW |
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/ic/ic.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-arguments-inl.h" | 8 #include "src/api-arguments-inl.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // TODO(jkummerow): Add support for "apply". The logic is roughly: | 104 // TODO(jkummerow): Add support for "apply". The logic is roughly: |
105 // marker = [fp_ + kMarkerOffset]; | 105 // marker = [fp_ + kMarkerOffset]; |
106 // if marker is smi and marker.value == INTERNAL and | 106 // if marker is smi and marker.value == INTERNAL and |
107 // the frame's code == builtin(Builtins::kFunctionApply): | 107 // the frame's code == builtin(Builtins::kFunctionApply): |
108 // then print "apply from" and advance one frame | 108 // then print "apply from" and advance one frame |
109 | 109 |
110 Object* maybe_function = | 110 Object* maybe_function = |
111 Memory::Object_at(fp_ + JavaScriptFrameConstants::kFunctionOffset); | 111 Memory::Object_at(fp_ + JavaScriptFrameConstants::kFunctionOffset); |
112 if (maybe_function->IsJSFunction()) { | 112 if (maybe_function->IsJSFunction()) { |
113 JSFunction* function = JSFunction::cast(maybe_function); | 113 JSFunction* function = JSFunction::cast(maybe_function); |
114 JavaScriptFrame::PrintFunctionAndOffset(function, function->code(), pc(), | 114 int code_offset = 0; |
115 stdout, true); | 115 if (function->code()->is_interpreter_trampoline_builtin()) { |
| 116 code_offset = InterpretedFrame::GetBytecodeOffset(fp()); |
| 117 } else { |
| 118 code_offset = |
| 119 static_cast<int>(pc() - function->code()->instruction_start()); |
| 120 } |
| 121 JavaScriptFrame::PrintFunctionAndOffset( |
| 122 function, function->abstract_code(), code_offset, stdout, true); |
116 } | 123 } |
117 | 124 |
118 const char* modifier = ""; | 125 const char* modifier = ""; |
119 if (kind() == Code::KEYED_STORE_IC) { | 126 if (kind() == Code::KEYED_STORE_IC) { |
120 KeyedAccessStoreMode mode = | 127 KeyedAccessStoreMode mode = |
121 casted_nexus<KeyedStoreICNexus>()->GetKeyedAccessStoreMode(); | 128 casted_nexus<KeyedStoreICNexus>()->GetKeyedAccessStoreMode(); |
122 modifier = GetTransitionMarkModifier(mode); | 129 modifier = GetTransitionMarkModifier(mode); |
123 } | 130 } |
124 void* map = nullptr; | 131 void* map = nullptr; |
125 if (!receiver_map().is_null()) { | 132 if (!receiver_map().is_null()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 const int kCallerPCOffset = StandardFrameConstants::kCallerPCOffset; | 171 const int kCallerPCOffset = StandardFrameConstants::kCallerPCOffset; |
165 pc_address = reinterpret_cast<Address*>(fp + kCallerPCOffset); | 172 pc_address = reinterpret_cast<Address*>(fp + kCallerPCOffset); |
166 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); | 173 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
167 } | 174 } |
168 #ifdef DEBUG | 175 #ifdef DEBUG |
169 StackFrameIterator it(isolate); | 176 StackFrameIterator it(isolate); |
170 for (int i = 0; i < depth + 1; i++) it.Advance(); | 177 for (int i = 0; i < depth + 1; i++) it.Advance(); |
171 StackFrame* frame = it.frame(); | 178 StackFrame* frame = it.frame(); |
172 DCHECK(fp == frame->fp() && pc_address == frame->pc_address()); | 179 DCHECK(fp == frame->fp() && pc_address == frame->pc_address()); |
173 #endif | 180 #endif |
| 181 // For interpreted functions, some bytecode handlers construct a |
| 182 // frame. We have to skip the constructed frame to find the interpreted |
| 183 // function's frame. Check if the there is an additional frame, and if there |
| 184 // is skip this frame. However, the pc should not be updated. The call to |
| 185 // ICs happen from bytecode handlers. |
| 186 Object* frame_type = |
| 187 Memory::Object_at(fp + TypedFrameConstants::kFrameTypeOffset); |
| 188 if (frame_type == Smi::FromInt(StackFrame::STUB)) { |
| 189 fp = Memory::Address_at(fp + TypedFrameConstants::kCallerFPOffset); |
| 190 } |
174 fp_ = fp; | 191 fp_ = fp; |
175 if (FLAG_enable_embedded_constant_pool) { | 192 if (FLAG_enable_embedded_constant_pool) { |
176 constant_pool_address_ = constant_pool; | 193 constant_pool_address_ = constant_pool; |
177 } | 194 } |
178 pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address); | 195 pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address); |
179 Code* target = this->target(); | 196 Code* target = this->target(); |
180 kind_ = target->kind(); | 197 kind_ = target->kind(); |
181 state_ = UseVector() ? nexus->StateFromFeedback() : StateFromCode(target); | 198 state_ = UseVector() ? nexus->StateFromFeedback() : StateFromCode(target); |
182 old_state_ = state_; | 199 old_state_ = state_; |
183 extra_ic_state_ = target->extra_ic_state(); | 200 extra_ic_state_ = target->extra_ic_state(); |
(...skipping 2729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2913 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); | 2930 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); |
2914 it.Next(); | 2931 it.Next(); |
2915 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 2932 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
2916 Object::GetProperty(&it)); | 2933 Object::GetProperty(&it)); |
2917 } | 2934 } |
2918 | 2935 |
2919 return *result; | 2936 return *result; |
2920 } | 2937 } |
2921 } // namespace internal | 2938 } // namespace internal |
2922 } // namespace v8 | 2939 } // namespace v8 |
OLD | NEW |