OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/assembler-arm64-inl.h" | 7 #include "src/arm64/assembler-arm64-inl.h" |
8 #include "src/arm64/frames-arm64.h" | 8 #include "src/arm64/frames-arm64.h" |
9 #include "src/arm64/macro-assembler-arm64-inl.h" | 9 #include "src/arm64/macro-assembler-arm64-inl.h" |
10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 // unoptimized | 1950 // unoptimized |
1951 // frame is still on the stack. Optimized code uses OSR values directly | 1951 // frame is still on the stack. Optimized code uses OSR values directly |
1952 // from | 1952 // from |
1953 // the unoptimized frame. Thus, all that needs to be done is to allocate | 1953 // the unoptimized frame. Thus, all that needs to be done is to allocate |
1954 // the | 1954 // the |
1955 // remaining stack slots. | 1955 // remaining stack slots. |
1956 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1956 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1957 osr_pc_offset_ = __ pc_offset(); | 1957 osr_pc_offset_ = __ pc_offset(); |
1958 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); | 1958 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); |
1959 } | 1959 } |
| 1960 |
| 1961 if (info()->IsWasm() && shrink_slots > 128) { |
| 1962 // For WebAssembly functions with big frames we have to do the stack |
| 1963 // overflow check before we construct the frame. Otherwise we may not |
| 1964 // have enough space on the stack to call the runtime for the stack |
| 1965 // overflow. |
| 1966 Label done; |
| 1967 // If the frame is bigger than the stack, we throw the stack overflow |
| 1968 // exception unconditionally. Thereby we can avoid the integer overflow |
| 1969 // check in the condition code. |
| 1970 if (shrink_slots * kPointerSize < FLAG_stack_size * 1024) { |
| 1971 UseScratchRegisterScope scope(masm()); |
| 1972 Register scratch = scope.AcquireX(); |
| 1973 __ Mov( |
| 1974 scratch, |
| 1975 Operand(ExternalReference::address_of_real_stack_limit(isolate()))); |
| 1976 __ Ldr(scratch, MemOperand(scratch)); |
| 1977 __ Add(scratch, scratch, Operand(shrink_slots * kPointerSize)); |
| 1978 __ Cmp(__ StackPointer(), scratch); |
| 1979 __ B(cs, &done); |
| 1980 } |
| 1981 |
| 1982 if (!frame_access_state()->has_frame()) { |
| 1983 __ set_has_frame(true); |
| 1984 // There is no need to leave the frame, we will not return from the |
| 1985 // runtime call. |
| 1986 __ EnterFrame(StackFrame::WASM_COMPILED); |
| 1987 } |
| 1988 DCHECK(__ StackPointer().Is(csp)); |
| 1989 __ SetStackPointer(jssp); |
| 1990 __ AssertStackConsistency(); |
| 1991 // Initialize the jssp because it is required for the runtime call. |
| 1992 __ Mov(jssp, csp); |
| 1993 __ Move(cp, Smi::kZero); |
| 1994 __ CallRuntime(Runtime::kThrowWasmStackOverflow); |
| 1995 // We come from WebAssembly, there are no references for the GC. |
| 1996 ReferenceMap* reference_map = new (zone()) ReferenceMap(zone()); |
| 1997 RecordSafepoint(reference_map, Safepoint::kSimple, 0, |
| 1998 Safepoint::kNoLazyDeopt); |
| 1999 if (FLAG_debug_code) { |
| 2000 __ Brk(0); |
| 2001 } |
| 2002 __ SetStackPointer(csp); |
| 2003 __ AssertStackConsistency(); |
| 2004 __ bind(&done); |
| 2005 } |
| 2006 |
1960 // Build remainder of frame, including accounting for and filling-in | 2007 // Build remainder of frame, including accounting for and filling-in |
1961 // frame-specific header information, e.g. claiming the extra slot that | 2008 // frame-specific header information, e.g. claiming the extra slot that |
1962 // other platforms explicitly push for STUB frames and frames recording | 2009 // other platforms explicitly push for STUB frames and frames recording |
1963 // their argument count. | 2010 // their argument count. |
1964 __ Claim(shrink_slots + (fixed_frame_size & 1)); | 2011 __ Claim(shrink_slots + (fixed_frame_size & 1)); |
1965 if (descriptor->PushArgumentCount()) { | 2012 if (descriptor->PushArgumentCount()) { |
1966 __ Str(kJavaScriptCallArgCountRegister, | 2013 __ Str(kJavaScriptCallArgCountRegister, |
1967 MemOperand(fp, OptimizedBuiltinFrameConstants::kArgCOffset)); | 2014 MemOperand(fp, OptimizedBuiltinFrameConstants::kArgCOffset)); |
1968 } | 2015 } |
1969 bool is_stub_frame = | 2016 bool is_stub_frame = |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 padding_size -= kInstructionSize; | 2292 padding_size -= kInstructionSize; |
2246 } | 2293 } |
2247 } | 2294 } |
2248 } | 2295 } |
2249 | 2296 |
2250 #undef __ | 2297 #undef __ |
2251 | 2298 |
2252 } // namespace compiler | 2299 } // namespace compiler |
2253 } // namespace internal | 2300 } // namespace internal |
2254 } // namespace v8 | 2301 } // namespace v8 |
OLD | NEW |