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

Side by Side Diff: src/frames.cc

Issue 1697223003: [Interpreter] GetExpression(0) in InterpretedFrames gets first local. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_push_bca
Patch Set: Created 4 years, 10 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
« no previous file with comments | « src/frames.h ('k') | test/mjsunit/mjsunit.status » ('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/frames.h" 5 #include "src/frames.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/ast/scopeinfo.h" 10 #include "src/ast/scopeinfo.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // together with the associated caller pc. 595 // together with the associated caller pc.
596 state->constant_pool_address = NULL; 596 state->constant_pool_address = NULL;
597 } 597 }
598 598
599 599
600 Address StandardFrame::GetExpressionAddress(int n) const { 600 Address StandardFrame::GetExpressionAddress(int n) const {
601 const int offset = StandardFrameConstants::kExpressionsOffset; 601 const int offset = StandardFrameConstants::kExpressionsOffset;
602 return fp() + offset - n * kPointerSize; 602 return fp() + offset - n * kPointerSize;
603 } 603 }
604 604
605 605 Address InterpretedFrame::GetExpressionAddress(int n) const {
606 Object* StandardFrame::GetExpression(Address fp, int index) { 606 const int offset = InterpreterFrameConstants::kExpressionsOffset;
607 return Memory::Object_at(GetExpressionAddress(fp, index)); 607 return fp() + offset - n * kPointerSize;
608 } 608 }
609 609
610
611 Address StandardFrame::GetExpressionAddress(Address fp, int n) {
612 const int offset = StandardFrameConstants::kExpressionsOffset;
613 return fp + offset - n * kPointerSize;
614 }
615
616
617 int StandardFrame::ComputeExpressionsCount() const { 610 int StandardFrame::ComputeExpressionsCount() const {
618 const int offset = 611 Address base = GetExpressionAddress(0);
619 StandardFrameConstants::kExpressionsOffset + kPointerSize; 612 Address limit = sp() - kPointerSize;
620 Address base = fp() + offset;
621 Address limit = sp();
622 DCHECK(base >= limit); // stack grows downwards 613 DCHECK(base >= limit); // stack grows downwards
623 // Include register-allocated locals in number of expressions. 614 // Include register-allocated locals in number of expressions.
624 return static_cast<int>((base - limit) / kPointerSize); 615 return static_cast<int>((base - limit) / kPointerSize);
625 } 616 }
626 617
627 618
628 void StandardFrame::ComputeCallerState(State* state) const { 619 void StandardFrame::ComputeCallerState(State* state) const {
629 state->sp = caller_sp(); 620 state->sp = caller_sp();
630 state->fp = caller_fp(); 621 state->fp = caller_fp();
631 state->pc_address = ResolveReturnAddressLocation( 622 state->pc_address = ResolveReturnAddressLocation(
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 bool JavaScriptFrame::HasInlinedFrames() const { 749 bool JavaScriptFrame::HasInlinedFrames() const {
759 List<JSFunction*> functions(1); 750 List<JSFunction*> functions(1);
760 GetFunctions(&functions); 751 GetFunctions(&functions);
761 return functions.length() > 1; 752 return functions.length() > 1;
762 } 753 }
763 754
764 755
765 int JavaScriptFrame::GetArgumentsLength() const { 756 int JavaScriptFrame::GetArgumentsLength() const {
766 // If there is an arguments adaptor frame get the arguments length from it. 757 // If there is an arguments adaptor frame get the arguments length from it.
767 if (has_adapted_arguments()) { 758 if (has_adapted_arguments()) {
768 STATIC_ASSERT(ArgumentsAdaptorFrameConstants::kLengthOffset == 759 return ArgumentsAdaptorFrame::GetLength(caller_fp());
769 StandardFrameConstants::kExpressionsOffset);
770 return Smi::cast(GetExpression(caller_fp(), 0))->value();
771 } else { 760 } else {
772 return GetNumberOfIncomingArguments(); 761 return GetNumberOfIncomingArguments();
773 } 762 }
774 } 763 }
775 764
776 765
777 Code* JavaScriptFrame::unchecked_code() const { 766 Code* JavaScriptFrame::unchecked_code() const {
778 return function()->code(); 767 return function()->code();
779 } 768 }
780 769
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 int InterpretedFrame::LookupExceptionHandlerInTable( 1120 int InterpretedFrame::LookupExceptionHandlerInTable(
1132 int* context_register, HandlerTable::CatchPrediction* prediction) { 1121 int* context_register, HandlerTable::CatchPrediction* prediction) {
1133 BytecodeArray* bytecode = function()->shared()->bytecode_array(); 1122 BytecodeArray* bytecode = function()->shared()->bytecode_array();
1134 HandlerTable* table = HandlerTable::cast(bytecode->handler_table()); 1123 HandlerTable* table = HandlerTable::cast(bytecode->handler_table());
1135 int pc_offset = GetBytecodeOffset() + 1; // Point after current bytecode. 1124 int pc_offset = GetBytecodeOffset() + 1; // Point after current bytecode.
1136 return table->LookupRange(pc_offset, context_register, prediction); 1125 return table->LookupRange(pc_offset, context_register, prediction);
1137 } 1126 }
1138 1127
1139 int InterpretedFrame::GetBytecodeOffset() const { 1128 int InterpretedFrame::GetBytecodeOffset() const {
1140 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; 1129 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex;
1141 DCHECK_EQ(InterpreterFrameConstants::kBytecodeOffsetFromFp, 1130 DCHECK_EQ(
1142 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); 1131 InterpreterFrameConstants::kBytecodeOffsetFromFp,
1132 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
1143 int raw_offset = Smi::cast(GetExpression(index))->value(); 1133 int raw_offset = Smi::cast(GetExpression(index))->value();
1144 return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; 1134 return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag;
1145 } 1135 }
1146 1136
1147 void InterpretedFrame::PatchBytecodeOffset(int new_offset) { 1137 void InterpretedFrame::PatchBytecodeOffset(int new_offset) {
1148 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; 1138 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex;
1149 DCHECK_EQ(InterpreterFrameConstants::kBytecodeOffsetFromFp, 1139 DCHECK_EQ(
1150 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); 1140 InterpreterFrameConstants::kBytecodeOffsetFromFp,
1141 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
1151 int raw_offset = new_offset + BytecodeArray::kHeaderSize - kHeapObjectTag; 1142 int raw_offset = new_offset + BytecodeArray::kHeaderSize - kHeapObjectTag;
1152 SetExpression(index, Smi::FromInt(raw_offset)); 1143 SetExpression(index, Smi::FromInt(raw_offset));
1153 } 1144 }
1154 1145
1155 Object* InterpretedFrame::GetBytecodeArray() const { 1146 Object* InterpretedFrame::GetBytecodeArray() const {
1156 const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex; 1147 const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex;
1157 DCHECK_EQ(InterpreterFrameConstants::kBytecodeArrayFromFp, 1148 DCHECK_EQ(
1158 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); 1149 InterpreterFrameConstants::kBytecodeArrayFromFp,
1150 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
1159 return GetExpression(index); 1151 return GetExpression(index);
1160 } 1152 }
1161 1153
1162 void InterpretedFrame::PatchBytecodeArray(Object* bytecode_array) { 1154 void InterpretedFrame::PatchBytecodeArray(Object* bytecode_array) {
1163 const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex; 1155 const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex;
1164 DCHECK_EQ(InterpreterFrameConstants::kBytecodeArrayFromFp, 1156 DCHECK_EQ(
1165 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); 1157 InterpreterFrameConstants::kBytecodeArrayFromFp,
1158 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
1166 SetExpression(index, bytecode_array); 1159 SetExpression(index, bytecode_array);
1167 } 1160 }
1168 1161
1169 Object* InterpretedFrame::GetInterpreterRegister(int register_index) const { 1162 Object* InterpretedFrame::GetInterpreterRegister(int register_index) const {
1170 const int index = InterpreterFrameConstants::kRegisterFileExpressionIndex; 1163 const int index = InterpreterFrameConstants::kRegisterFileExpressionIndex;
1171 DCHECK_EQ(InterpreterFrameConstants::kRegisterFilePointerFromFp, 1164 DCHECK_EQ(
1172 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); 1165 InterpreterFrameConstants::kRegisterFilePointerFromFp,
1166 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
1173 return GetExpression(index + register_index); 1167 return GetExpression(index + register_index);
1174 } 1168 }
1175 1169
1176 void InterpretedFrame::Summarize(List<FrameSummary>* functions) { 1170 void InterpretedFrame::Summarize(List<FrameSummary>* functions) {
1177 DCHECK(functions->length() == 0); 1171 DCHECK(functions->length() == 0);
1178 AbstractCode* abstract_code = 1172 AbstractCode* abstract_code =
1179 AbstractCode::cast(function()->shared()->bytecode_array()); 1173 AbstractCode::cast(function()->shared()->bytecode_array());
1180 FrameSummary summary(receiver(), function(), abstract_code, 1174 FrameSummary summary(receiver(), function(), abstract_code,
1181 GetBytecodeOffset(), IsConstructor()); 1175 GetBytecodeOffset(), IsConstructor());
1182 functions->Add(summary); 1176 functions->Add(summary);
1183 } 1177 }
1184 1178
1185 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { 1179 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const {
1186 return Smi::cast(GetExpression(0))->value(); 1180 return Smi::cast(GetExpression(0))->value();
1187 } 1181 }
1188 1182
1189 1183
1190 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { 1184 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const {
1191 return fp() + StandardFrameConstants::kCallerSPOffset; 1185 return fp() + StandardFrameConstants::kCallerSPOffset;
1192 } 1186 }
1193 1187
1188 int ArgumentsAdaptorFrame::GetLength(Address fp) {
1189 const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset;
1190 return Smi::cast(Memory::Object_at(fp + offset))->value();
1191 }
1192
1193 Code* ArgumentsAdaptorFrame::unchecked_code() const {
1194 return isolate()->builtins()->builtin(
1195 Builtins::kArgumentsAdaptorTrampoline);
1196 }
1194 1197
1195 Address InternalFrame::GetCallerStackPointer() const { 1198 Address InternalFrame::GetCallerStackPointer() const {
1196 // Internal frames have no arguments. The stack pointer of the 1199 // Internal frames have no arguments. The stack pointer of the
1197 // caller is at a fixed offset from the frame pointer. 1200 // caller is at a fixed offset from the frame pointer.
1198 return fp() + StandardFrameConstants::kCallerSPOffset; 1201 return fp() + StandardFrameConstants::kCallerSPOffset;
1199 } 1202 }
1200 1203
1201
1202 Code* ArgumentsAdaptorFrame::unchecked_code() const {
1203 return isolate()->builtins()->builtin(
1204 Builtins::kArgumentsAdaptorTrampoline);
1205 }
1206
1207
1208 Code* InternalFrame::unchecked_code() const { 1204 Code* InternalFrame::unchecked_code() const {
1209 const int offset = InternalFrameConstants::kCodeOffset; 1205 const int offset = InternalFrameConstants::kCodeOffset;
1210 Object* code = Memory::Object_at(fp() + offset); 1206 Object* code = Memory::Object_at(fp() + offset);
1211 DCHECK(code != NULL); 1207 DCHECK(code != NULL);
1212 return reinterpret_cast<Code*>(code); 1208 return reinterpret_cast<Code*>(code);
1213 } 1209 }
1214 1210
1215 1211
1216 void StackFrame::PrintIndex(StringStream* accumulator, 1212 void StackFrame::PrintIndex(StringStream* accumulator,
1217 PrintMode mode, 1213 PrintMode mode,
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1639 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1644 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1640 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1645 list.Add(frame, zone); 1641 list.Add(frame, zone);
1646 } 1642 }
1647 return list.ToVector(); 1643 return list.ToVector();
1648 } 1644 }
1649 1645
1650 1646
1651 } // namespace internal 1647 } // namespace internal
1652 } // namespace v8 1648 } // namespace v8
OLDNEW
« no previous file with comments | « src/frames.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698