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

Side by Side Diff: src/mips/builtins-mips.cc

Issue 1904093002: [interpreter] Heal closures when bytecode array is gone. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ported to most architectures. Created 4 years, 8 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/ia32/builtins-ia32.cc ('k') | src/mips64/builtins-mips64.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 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 // frames.h for its layout. 976 // frames.h for its layout.
977 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { 977 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
978 ProfileEntryHookStub::MaybeCallEntryHook(masm); 978 ProfileEntryHookStub::MaybeCallEntryHook(masm);
979 979
980 // Open a frame scope to indicate that there is a frame on the stack. The 980 // Open a frame scope to indicate that there is a frame on the stack. The
981 // MANUAL indicates that the scope shouldn't actually generate code to set up 981 // MANUAL indicates that the scope shouldn't actually generate code to set up
982 // the frame (that is done below). 982 // the frame (that is done below).
983 FrameScope frame_scope(masm, StackFrame::MANUAL); 983 FrameScope frame_scope(masm, StackFrame::MANUAL);
984 __ PushStandardFrame(a1); 984 __ PushStandardFrame(a1);
985 985
986 // Get the bytecode array from the function object and load the pointer to the 986 // Get the bytecode array from the function object (or from the DebugInfo if
987 // first entry into kInterpreterBytecodeRegister. 987 // it is present) and load it into kInterpreterBytecodeArrayRegister.
988 __ lw(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 988 __ lw(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
989 Label load_debug_bytecode_array, bytecode_array_loaded; 989 Label load_debug_bytecode_array, bytecode_array_loaded;
990 Register debug_info = kInterpreterBytecodeArrayRegister; 990 Register debug_info = kInterpreterBytecodeArrayRegister;
991 DCHECK(!debug_info.is(a0)); 991 DCHECK(!debug_info.is(a0));
992 __ lw(debug_info, FieldMemOperand(a0, SharedFunctionInfo::kDebugInfoOffset)); 992 __ lw(debug_info, FieldMemOperand(a0, SharedFunctionInfo::kDebugInfoOffset));
993 __ Branch(&load_debug_bytecode_array, ne, debug_info, 993 __ Branch(&load_debug_bytecode_array, ne, debug_info,
994 Operand(DebugInfo::uninitialized())); 994 Operand(DebugInfo::uninitialized()));
995 __ lw(kInterpreterBytecodeArrayRegister, 995 __ lw(kInterpreterBytecodeArrayRegister,
996 FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset)); 996 FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset));
997 __ bind(&bytecode_array_loaded); 997 __ bind(&bytecode_array_loaded);
998 998
999 // Check function data field is actually a BytecodeArray object.
1000 Label bytecode_array_not_present;
1001 __ JumpIfRoot(kInterpreterBytecodeArrayRegister,
1002 Heap::kUndefinedValueRootIndex, &bytecode_array_not_present);
999 if (FLAG_debug_code) { 1003 if (FLAG_debug_code) {
1000 // Check function data field is actually a BytecodeArray object.
1001 __ SmiTst(kInterpreterBytecodeArrayRegister, t0); 1004 __ SmiTst(kInterpreterBytecodeArrayRegister, t0);
1002 __ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, t0, 1005 __ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, t0,
1003 Operand(zero_reg)); 1006 Operand(zero_reg));
1004 __ GetObjectType(kInterpreterBytecodeArrayRegister, t0, t0); 1007 __ GetObjectType(kInterpreterBytecodeArrayRegister, t0, t0);
1005 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, t0, 1008 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, t0,
1006 Operand(BYTECODE_ARRAY_TYPE)); 1009 Operand(BYTECODE_ARRAY_TYPE));
1007 } 1010 }
1008 1011
1009 // Push new.target, bytecode array and zero for bytecode array offset. 1012 // Push new.target, bytecode array and zero for bytecode array offset.
1010 __ Push(a3, kInterpreterBytecodeArrayRegister, zero_reg); 1013 __ Push(a3, kInterpreterBytecodeArrayRegister, zero_reg);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 __ Call(at); 1058 __ Call(at);
1056 1059
1057 // Even though the first bytecode handler was called, we will never return. 1060 // Even though the first bytecode handler was called, we will never return.
1058 __ Abort(kUnexpectedReturnFromBytecodeHandler); 1061 __ Abort(kUnexpectedReturnFromBytecodeHandler);
1059 1062
1060 // Load debug copy of the bytecode array. 1063 // Load debug copy of the bytecode array.
1061 __ bind(&load_debug_bytecode_array); 1064 __ bind(&load_debug_bytecode_array);
1062 __ lw(kInterpreterBytecodeArrayRegister, 1065 __ lw(kInterpreterBytecodeArrayRegister,
1063 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); 1066 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex));
1064 __ Branch(&bytecode_array_loaded); 1067 __ Branch(&bytecode_array_loaded);
1068
1069 // If the bytecode array is no longer present, then the underlying function
1070 // has been switched to a different kind of code and we heal the closure by
1071 // switching the code entry field over to the new code object as well.
1072 __ bind(&bytecode_array_not_present);
1073 __ LeaveFrame(StackFrame::JAVA_SCRIPT);
1074 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1075 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kCodeOffset));
1076 __ Addu(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag));
1077 __ sw(t0, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
1078 __ RecordWriteCodeEntryField(a1, t0, t1);
1079 __ Jump(t0);
1065 } 1080 }
1066 1081
1067 1082
1068 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { 1083 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
1069 // The return value is in accumulator, which is already in v0. 1084 // The return value is in accumulator, which is already in v0.
1070 1085
1071 // Leave the frame (also dropping the register file). 1086 // Leave the frame (also dropping the register file).
1072 __ LeaveFrame(StackFrame::JAVA_SCRIPT); 1087 __ LeaveFrame(StackFrame::JAVA_SCRIPT);
1073 1088
1074 // Drop receiver + arguments and return. 1089 // Drop receiver + arguments and return.
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 } 2872 }
2858 } 2873 }
2859 2874
2860 2875
2861 #undef __ 2876 #undef __
2862 2877
2863 } // namespace internal 2878 } // namespace internal
2864 } // namespace v8 2879 } // namespace v8
2865 2880
2866 #endif // V8_TARGET_ARCH_MIPS 2881 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/mips64/builtins-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698