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

Side by Side Diff: src/frames.cc

Issue 2629113004: Revert of [runtime] Change JavaScriptFrame::GetFunctions interface. (Closed)
Patch Set: Created 3 years, 11 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') | src/runtime-profiler.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 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 <memory> 7 #include <memory>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 Address fp = caller_fp(); 919 Address fp = caller_fp();
920 if (has_adapted_arguments()) { 920 if (has_adapted_arguments()) {
921 // Skip the arguments adaptor frame and look at the real caller. 921 // Skip the arguments adaptor frame and look at the real caller.
922 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); 922 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset);
923 } 923 }
924 return IsConstructFrame(fp); 924 return IsConstructFrame(fp);
925 } 925 }
926 926
927 927
928 bool JavaScriptFrame::HasInlinedFrames() const { 928 bool JavaScriptFrame::HasInlinedFrames() const {
929 List<SharedFunctionInfo*> functions(1); 929 List<JSFunction*> functions(1);
930 GetFunctions(&functions); 930 GetFunctions(&functions);
931 return functions.length() > 1; 931 return functions.length() > 1;
932 } 932 }
933 933
934 934
935 int JavaScriptFrame::GetArgumentsLength() const { 935 int JavaScriptFrame::GetArgumentsLength() const {
936 // If there is an arguments adaptor frame get the arguments length from it. 936 // If there is an arguments adaptor frame get the arguments length from it.
937 if (has_adapted_arguments()) { 937 if (has_adapted_arguments()) {
938 return ArgumentsAdaptorFrame::GetLength(caller_fp()); 938 return ArgumentsAdaptorFrame::GetLength(caller_fp());
939 } else { 939 } else {
(...skipping 12 matching lines...) Expand all
952 isolate()->heap()->gc_state() == Heap::NOT_IN_GC); 952 isolate()->heap()->gc_state() == Heap::NOT_IN_GC);
953 953
954 return function()->shared()->internal_formal_parameter_count(); 954 return function()->shared()->internal_formal_parameter_count();
955 } 955 }
956 956
957 957
958 Address JavaScriptFrame::GetCallerStackPointer() const { 958 Address JavaScriptFrame::GetCallerStackPointer() const {
959 return fp() + StandardFrameConstants::kCallerSPOffset; 959 return fp() + StandardFrameConstants::kCallerSPOffset;
960 } 960 }
961 961
962 void JavaScriptFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const { 962
963 void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) const {
963 DCHECK(functions->length() == 0); 964 DCHECK(functions->length() == 0);
964 functions->Add(function()->shared()); 965 functions->Add(function());
965 } 966 }
966 967
967 void JavaScriptFrame::Summarize(List<FrameSummary>* functions, 968 void JavaScriptFrame::Summarize(List<FrameSummary>* functions,
968 FrameSummary::Mode mode) const { 969 FrameSummary::Mode mode) const {
969 DCHECK(functions->length() == 0); 970 DCHECK(functions->length() == 0);
970 Code* code = LookupCode(); 971 Code* code = LookupCode();
971 int offset = static_cast<int>(pc() - code->instruction_start()); 972 int offset = static_cast<int>(pc() - code->instruction_start());
972 AbstractCode* abstract_code = AbstractCode::cast(code); 973 AbstractCode* abstract_code = AbstractCode::cast(code);
973 FrameSummary summary(receiver(), function(), abstract_code, offset, 974 FrameSummary summary(receiver(), function(), abstract_code, offset,
974 IsConstructor(), mode); 975 IsConstructor(), mode);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 intptr_t argc = *reinterpret_cast<intptr_t*>(argc_ptr); 1333 intptr_t argc = *reinterpret_cast<intptr_t*>(argc_ptr);
1333 intptr_t args_size = 1334 intptr_t args_size =
1334 (StandardFrameConstants::kFixedSlotCountAboveFp + argc) * kPointerSize; 1335 (StandardFrameConstants::kFixedSlotCountAboveFp + argc) * kPointerSize;
1335 Address receiver_ptr = fp() + args_size; 1336 Address receiver_ptr = fp() + args_size;
1336 return *reinterpret_cast<Object**>(receiver_ptr); 1337 return *reinterpret_cast<Object**>(receiver_ptr);
1337 } else { 1338 } else {
1338 return JavaScriptFrame::receiver(); 1339 return JavaScriptFrame::receiver();
1339 } 1340 }
1340 } 1341 }
1341 1342
1342 void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const { 1343 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) const {
1343 DCHECK(functions->length() == 0); 1344 DCHECK(functions->length() == 0);
1344 DCHECK(is_optimized()); 1345 DCHECK(is_optimized());
1345 1346
1346 // Delegate to JS frame in absence of turbofan deoptimization. 1347 // Delegate to JS frame in absence of turbofan deoptimization.
1347 // TODO(turbofan): Revisit once we support deoptimization across the board. 1348 // TODO(turbofan): Revisit once we support deoptimization across the board.
1348 Code* code = LookupCode(); 1349 Code* code = LookupCode();
1349 if (code->kind() == Code::BUILTIN || 1350 if (code->kind() == Code::BUILTIN ||
1350 CannotDeoptFromAsmCode(code, function())) { 1351 CannotDeoptFromAsmCode(code, function())) {
1351 return JavaScriptFrame::GetFunctions(functions); 1352 return JavaScriptFrame::GetFunctions(functions);
1352 } 1353 }
1353 1354
1354 DisallowHeapAllocation no_gc; 1355 DisallowHeapAllocation no_gc;
1355 int deopt_index = Safepoint::kNoDeoptimizationIndex; 1356 int deopt_index = Safepoint::kNoDeoptimizationIndex;
1356 DeoptimizationInputData* const data = GetDeoptimizationData(&deopt_index); 1357 DeoptimizationInputData* const data = GetDeoptimizationData(&deopt_index);
1357 DCHECK_NOT_NULL(data); 1358 DCHECK_NOT_NULL(data);
1358 DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index); 1359 DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index);
1359 FixedArray* const literal_array = data->LiteralArray(); 1360 FixedArray* const literal_array = data->LiteralArray();
1360 1361
1361 TranslationIterator it(data->TranslationByteArray(), 1362 TranslationIterator it(data->TranslationByteArray(),
1362 data->TranslationIndex(deopt_index)->value()); 1363 data->TranslationIndex(deopt_index)->value());
1363 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); 1364 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
1364 DCHECK_EQ(Translation::BEGIN, opcode); 1365 DCHECK_EQ(Translation::BEGIN, opcode);
1365 it.Next(); // Skip frame count. 1366 it.Next(); // Skip frame count.
1366 int jsframe_count = it.Next(); 1367 int jsframe_count = it.Next();
1367 1368
1368 // We insert the frames in reverse order because the frames 1369 // We insert the frames in reverse order because the frames
1369 // in the deoptimization translation are ordered bottom-to-top. 1370 // in the deoptimization translation are ordered bottom-to-top.
1370 while (jsframe_count != 0) { 1371 while (jsframe_count != 0) {
1371 opcode = static_cast<Translation::Opcode>(it.Next()); 1372 opcode = static_cast<Translation::Opcode>(it.Next());
1373 // Skip over operands to advance to the next opcode.
1374 it.Skip(Translation::NumberOfOperandsFor(opcode));
1372 if (opcode == Translation::JS_FRAME || 1375 if (opcode == Translation::JS_FRAME ||
1373 opcode == Translation::INTERPRETED_FRAME) { 1376 opcode == Translation::INTERPRETED_FRAME) {
1374 it.Next(); // Skip bailout id.
1375 jsframe_count--; 1377 jsframe_count--;
1376 1378
1377 // The second operand of the frame points to the function. 1379 // The translation commands are ordered and the function is always at the
1378 Object* shared = literal_array->get(it.Next()); 1380 // first position.
1379 functions->Add(SharedFunctionInfo::cast(shared)); 1381 opcode = static_cast<Translation::Opcode>(it.Next());
1380 1382
1381 // Skip over remaining operands to advance to the next opcode. 1383 // Get the correct function in the optimized frame.
1382 it.Skip(Translation::NumberOfOperandsFor(opcode) - 2); 1384 Object* function;
1383 } else { 1385 if (opcode == Translation::LITERAL) {
1384 // Skip over operands to advance to the next opcode. 1386 function = literal_array->get(it.Next());
1385 it.Skip(Translation::NumberOfOperandsFor(opcode)); 1387 } else {
1388 CHECK_EQ(Translation::STACK_SLOT, opcode);
1389 function = StackSlotAt(it.Next());
1390 }
1391 functions->Add(JSFunction::cast(function));
1386 } 1392 }
1387 } 1393 }
1388 } 1394 }
1389 1395
1390 1396
1391 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { 1397 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) {
1392 return StandardFrameConstants::kCallerSPOffset - 1398 return StandardFrameConstants::kCallerSPOffset -
1393 ((slot_index + 1) * kPointerSize); 1399 ((slot_index + 1) * kPointerSize);
1394 } 1400 }
1395 1401
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 2096 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
2091 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 2097 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
2092 list.Add(frame, zone); 2098 list.Add(frame, zone);
2093 } 2099 }
2094 return list.ToVector(); 2100 return list.ToVector();
2095 } 2101 }
2096 2102
2097 2103
2098 } // namespace internal 2104 } // namespace internal
2099 } // namespace v8 2105 } // namespace v8
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698