| 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/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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 it.Next(); // Skip height. | 962 it.Next(); // Skip height. |
| 963 | 963 |
| 964 // The translation commands are ordered and the function is always | 964 // The translation commands are ordered and the function is always |
| 965 // at the first position, and the receiver is next. | 965 // at the first position, and the receiver is next. |
| 966 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 966 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 967 | 967 |
| 968 // Get the correct function in the optimized frame. | 968 // Get the correct function in the optimized frame. |
| 969 JSFunction* function; | 969 JSFunction* function; |
| 970 if (opcode == Translation::LITERAL) { | 970 if (opcode == Translation::LITERAL) { |
| 971 function = JSFunction::cast(literal_array->get(it.Next())); | 971 function = JSFunction::cast(literal_array->get(it.Next())); |
| 972 } else if (opcode == Translation::STACK_SLOT) { | 972 } else { |
| 973 CHECK_EQ(opcode, Translation::STACK_SLOT); |
| 973 function = JSFunction::cast(StackSlotAt(it.Next())); | 974 function = JSFunction::cast(StackSlotAt(it.Next())); |
| 974 } else { | |
| 975 CHECK_EQ(Translation::JS_FRAME_FUNCTION, opcode); | |
| 976 function = this->function(); | |
| 977 } | 975 } |
| 978 DCHECK_EQ(shared_info, function->shared()); | 976 DCHECK_EQ(shared_info, function->shared()); |
| 979 | 977 |
| 980 // If we are at a call, the receiver is always in a stack slot. | 978 // If we are at a call, the receiver is always in a stack slot. |
| 981 // Otherwise we are not guaranteed to get the receiver value. | 979 // Otherwise we are not guaranteed to get the receiver value. |
| 982 opcode = static_cast<Translation::Opcode>(it.Next()); | 980 opcode = static_cast<Translation::Opcode>(it.Next()); |
| 983 | 981 |
| 984 // Get the correct receiver in the optimized frame. | 982 // Get the correct receiver in the optimized frame. |
| 985 Object* receiver; | 983 Object* receiver; |
| 986 if (opcode == Translation::LITERAL) { | 984 if (opcode == Translation::LITERAL) { |
| 987 receiver = literal_array->get(it.Next()); | 985 receiver = literal_array->get(it.Next()); |
| 988 } else if (opcode == Translation::STACK_SLOT) { | 986 } else if (opcode == Translation::STACK_SLOT) { |
| 989 receiver = StackSlotAt(it.Next()); | 987 receiver = StackSlotAt(it.Next()); |
| 990 } else if (opcode == Translation::JS_FRAME_FUNCTION) { | |
| 991 receiver = this->function(); | |
| 992 } else { | 988 } else { |
| 993 // The receiver is not in a stack slot nor in a literal. We give up. | 989 // The receiver is not in a stack slot nor in a literal. We give up. |
| 994 it.Skip(Translation::NumberOfOperandsFor(opcode)); | 990 it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| 995 // TODO(3029): Materializing a captured object (or duplicated | 991 // TODO(3029): Materializing a captured object (or duplicated |
| 996 // object) is hard, we return undefined for now. This breaks the | 992 // object) is hard, we return undefined for now. This breaks the |
| 997 // produced stack trace, as constructor frames aren't marked as | 993 // produced stack trace, as constructor frames aren't marked as |
| 998 // such anymore. | 994 // such anymore. |
| 999 receiver = isolate()->heap()->undefined_value(); | 995 receiver = isolate()->heap()->undefined_value(); |
| 1000 } | 996 } |
| 1001 | 997 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 jsframe_count--; | 1101 jsframe_count--; |
| 1106 | 1102 |
| 1107 // The translation commands are ordered and the function is always at the | 1103 // The translation commands are ordered and the function is always at the |
| 1108 // first position. | 1104 // first position. |
| 1109 opcode = static_cast<Translation::Opcode>(it.Next()); | 1105 opcode = static_cast<Translation::Opcode>(it.Next()); |
| 1110 | 1106 |
| 1111 // Get the correct function in the optimized frame. | 1107 // Get the correct function in the optimized frame. |
| 1112 Object* function; | 1108 Object* function; |
| 1113 if (opcode == Translation::LITERAL) { | 1109 if (opcode == Translation::LITERAL) { |
| 1114 function = literal_array->get(it.Next()); | 1110 function = literal_array->get(it.Next()); |
| 1115 } else if (opcode == Translation::STACK_SLOT) { | 1111 } else { |
| 1112 CHECK_EQ(Translation::STACK_SLOT, opcode); |
| 1116 function = StackSlotAt(it.Next()); | 1113 function = StackSlotAt(it.Next()); |
| 1117 } else { | |
| 1118 CHECK_EQ(Translation::JS_FRAME_FUNCTION, opcode); | |
| 1119 function = this->function(); | |
| 1120 } | 1114 } |
| 1121 functions->Add(JSFunction::cast(function)); | 1115 functions->Add(JSFunction::cast(function)); |
| 1122 } | 1116 } |
| 1123 } | 1117 } |
| 1124 } | 1118 } |
| 1125 | 1119 |
| 1126 | 1120 |
| 1127 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { | 1121 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { |
| 1128 return StandardFrameConstants::kCallerSPOffset - | 1122 return StandardFrameConstants::kCallerSPOffset - |
| 1129 ((slot_index + 1) * kPointerSize); | 1123 ((slot_index + 1) * kPointerSize); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1632 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1639 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1633 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1640 list.Add(frame, zone); | 1634 list.Add(frame, zone); |
| 1641 } | 1635 } |
| 1642 return list.ToVector(); | 1636 return list.ToVector(); |
| 1643 } | 1637 } |
| 1644 | 1638 |
| 1645 | 1639 |
| 1646 } // namespace internal | 1640 } // namespace internal |
| 1647 } // namespace v8 | 1641 } // namespace v8 |
| OLD | NEW |