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

Side by Side Diff: src/frames.cc

Issue 2626213002: [runtime] Change JavaScriptFrame::GetFunctions interface. (Closed)
Patch Set: Rebased. 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<JSFunction*> functions(1); 929 List<SharedFunctionInfo*> 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 962 void JavaScriptFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const {
963 void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) const {
964 DCHECK(functions->length() == 0); 963 DCHECK(functions->length() == 0);
965 functions->Add(function()); 964 functions->Add(function()->shared());
966 } 965 }
967 966
968 void JavaScriptFrame::Summarize(List<FrameSummary>* functions, 967 void JavaScriptFrame::Summarize(List<FrameSummary>* functions,
969 FrameSummary::Mode mode) const { 968 FrameSummary::Mode mode) const {
970 DCHECK(functions->length() == 0); 969 DCHECK(functions->length() == 0);
971 Code* code = LookupCode(); 970 Code* code = LookupCode();
972 int offset = static_cast<int>(pc() - code->instruction_start()); 971 int offset = static_cast<int>(pc() - code->instruction_start());
973 AbstractCode* abstract_code = AbstractCode::cast(code); 972 AbstractCode* abstract_code = AbstractCode::cast(code);
974 FrameSummary::JavaScriptFrameSummary summary(isolate(), receiver(), 973 FrameSummary::JavaScriptFrameSummary summary(isolate(), receiver(),
975 function(), abstract_code, 974 function(), abstract_code,
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 intptr_t argc = *reinterpret_cast<intptr_t*>(argc_ptr); 1466 intptr_t argc = *reinterpret_cast<intptr_t*>(argc_ptr);
1468 intptr_t args_size = 1467 intptr_t args_size =
1469 (StandardFrameConstants::kFixedSlotCountAboveFp + argc) * kPointerSize; 1468 (StandardFrameConstants::kFixedSlotCountAboveFp + argc) * kPointerSize;
1470 Address receiver_ptr = fp() + args_size; 1469 Address receiver_ptr = fp() + args_size;
1471 return *reinterpret_cast<Object**>(receiver_ptr); 1470 return *reinterpret_cast<Object**>(receiver_ptr);
1472 } else { 1471 } else {
1473 return JavaScriptFrame::receiver(); 1472 return JavaScriptFrame::receiver();
1474 } 1473 }
1475 } 1474 }
1476 1475
1477 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) const { 1476 void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const {
1478 DCHECK(functions->length() == 0); 1477 DCHECK(functions->length() == 0);
1479 DCHECK(is_optimized()); 1478 DCHECK(is_optimized());
1480 1479
1481 // Delegate to JS frame in absence of turbofan deoptimization. 1480 // Delegate to JS frame in absence of turbofan deoptimization.
1482 // TODO(turbofan): Revisit once we support deoptimization across the board. 1481 // TODO(turbofan): Revisit once we support deoptimization across the board.
1483 Code* code = LookupCode(); 1482 Code* code = LookupCode();
1484 if (code->kind() == Code::BUILTIN || 1483 if (code->kind() == Code::BUILTIN ||
1485 CannotDeoptFromAsmCode(code, function())) { 1484 CannotDeoptFromAsmCode(code, function())) {
1486 return JavaScriptFrame::GetFunctions(functions); 1485 return JavaScriptFrame::GetFunctions(functions);
1487 } 1486 }
1488 1487
1489 DisallowHeapAllocation no_gc; 1488 DisallowHeapAllocation no_gc;
1490 int deopt_index = Safepoint::kNoDeoptimizationIndex; 1489 int deopt_index = Safepoint::kNoDeoptimizationIndex;
1491 DeoptimizationInputData* const data = GetDeoptimizationData(&deopt_index); 1490 DeoptimizationInputData* const data = GetDeoptimizationData(&deopt_index);
1492 DCHECK_NOT_NULL(data); 1491 DCHECK_NOT_NULL(data);
1493 DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index); 1492 DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index);
1494 FixedArray* const literal_array = data->LiteralArray(); 1493 FixedArray* const literal_array = data->LiteralArray();
1495 1494
1496 TranslationIterator it(data->TranslationByteArray(), 1495 TranslationIterator it(data->TranslationByteArray(),
1497 data->TranslationIndex(deopt_index)->value()); 1496 data->TranslationIndex(deopt_index)->value());
1498 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); 1497 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
1499 DCHECK_EQ(Translation::BEGIN, opcode); 1498 DCHECK_EQ(Translation::BEGIN, opcode);
1500 it.Next(); // Skip frame count. 1499 it.Next(); // Skip frame count.
1501 int jsframe_count = it.Next(); 1500 int jsframe_count = it.Next();
1502 1501
1503 // We insert the frames in reverse order because the frames 1502 // We insert the frames in reverse order because the frames
1504 // in the deoptimization translation are ordered bottom-to-top. 1503 // in the deoptimization translation are ordered bottom-to-top.
1505 while (jsframe_count != 0) { 1504 while (jsframe_count != 0) {
1506 opcode = static_cast<Translation::Opcode>(it.Next()); 1505 opcode = static_cast<Translation::Opcode>(it.Next());
1507 // Skip over operands to advance to the next opcode.
1508 it.Skip(Translation::NumberOfOperandsFor(opcode));
1509 if (opcode == Translation::JS_FRAME || 1506 if (opcode == Translation::JS_FRAME ||
1510 opcode == Translation::INTERPRETED_FRAME) { 1507 opcode == Translation::INTERPRETED_FRAME) {
1508 it.Next(); // Skip bailout id.
1511 jsframe_count--; 1509 jsframe_count--;
1512 1510
1513 // The translation commands are ordered and the function is always at the 1511 // The second operand of the frame points to the function.
1514 // first position. 1512 Object* shared = literal_array->get(it.Next());
1515 opcode = static_cast<Translation::Opcode>(it.Next()); 1513 functions->Add(SharedFunctionInfo::cast(shared));
1516 1514
1517 // Get the correct function in the optimized frame. 1515 // Skip over remaining operands to advance to the next opcode.
1518 Object* function; 1516 it.Skip(Translation::NumberOfOperandsFor(opcode) - 2);
1519 if (opcode == Translation::LITERAL) { 1517 } else {
1520 function = literal_array->get(it.Next()); 1518 // Skip over operands to advance to the next opcode.
1521 } else { 1519 it.Skip(Translation::NumberOfOperandsFor(opcode));
1522 CHECK_EQ(Translation::STACK_SLOT, opcode);
1523 function = StackSlotAt(it.Next());
1524 }
1525 functions->Add(JSFunction::cast(function));
1526 } 1520 }
1527 } 1521 }
1528 } 1522 }
1529 1523
1530 1524
1531 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { 1525 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) {
1532 return StandardFrameConstants::kCallerSPOffset - 1526 return StandardFrameConstants::kCallerSPOffset -
1533 ((slot_index + 1) * kPointerSize); 1527 ((slot_index + 1) * kPointerSize);
1534 } 1528 }
1535 1529
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 2219 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
2226 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 2220 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
2227 list.Add(frame, zone); 2221 list.Add(frame, zone);
2228 } 2222 }
2229 return list.ToVector(); 2223 return list.ToVector();
2230 } 2224 }
2231 2225
2232 2226
2233 } // namespace internal 2227 } // namespace internal
2234 } // namespace v8 2228 } // 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