| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // modification, are permitted provided that the following conditions are | 3 // found in the LICENSE file. |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 | 4 |
| 28 #ifndef V8_EXECUTION_H_ | 5 #ifndef V8_EXECUTION_H_ |
| 29 #define V8_EXECUTION_H_ | 6 #define V8_EXECUTION_H_ |
| 30 | 7 |
| 31 #include "allocation.h" | 8 #include "handles.h" |
| 32 | 9 |
| 33 namespace v8 { | 10 namespace v8 { |
| 34 namespace internal { | 11 namespace internal { |
| 35 | 12 |
| 36 | |
| 37 // Flag used to set the interrupt causes. | 13 // Flag used to set the interrupt causes. |
| 38 enum InterruptFlag { | 14 enum InterruptFlag { |
| 39 INTERRUPT = 1 << 0, | 15 INTERRUPT = 1 << 0, |
| 40 DEBUGBREAK = 1 << 1, | 16 DEBUGBREAK = 1 << 1, |
| 41 DEBUGCOMMAND = 1 << 2, | 17 DEBUGCOMMAND = 1 << 2, |
| 42 PREEMPT = 1 << 3, | 18 PREEMPT = 1 << 3, |
| 43 TERMINATE = 1 << 4, | 19 TERMINATE = 1 << 4, |
| 44 GC_REQUEST = 1 << 5, | 20 GC_REQUEST = 1 << 5, |
| 45 FULL_DEOPT = 1 << 6, | 21 FULL_DEOPT = 1 << 6, |
| 46 INSTALL_CODE = 1 << 7, | 22 INSTALL_CODE = 1 << 7, |
| 47 API_INTERRUPT = 1 << 8, | 23 API_INTERRUPT = 1 << 8, |
| 48 DEOPT_MARKED_ALLOCATION_SITES = 1 << 9 | 24 DEOPT_MARKED_ALLOCATION_SITES = 1 << 9 |
| 49 }; | 25 }; |
| 50 | 26 |
| 51 | 27 |
| 52 class Isolate; | 28 class Execution V8_FINAL : public AllStatic { |
| 53 | |
| 54 | |
| 55 class Execution : public AllStatic { | |
| 56 public: | 29 public: |
| 57 // Call a function, the caller supplies a receiver and an array | 30 // Call a function, the caller supplies a receiver and an array |
| 58 // of arguments. Arguments are Object* type. After function returns, | 31 // of arguments. Arguments are Object* type. After function returns, |
| 59 // pointers in 'args' might be invalid. | 32 // pointers in 'args' might be invalid. |
| 60 // | 33 // |
| 61 // *pending_exception tells whether the invoke resulted in | 34 // *pending_exception tells whether the invoke resulted in |
| 62 // a pending exception. | 35 // a pending exception. |
| 63 // | 36 // |
| 64 // When convert_receiver is set, and the receiver is not an object, | 37 // When convert_receiver is set, and the receiver is not an object, |
| 65 // and the function called is not in strict mode, receiver is converted to | 38 // and the function called is not in strict mode, receiver is converted to |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 static void EnqueueMicrotask(Isolate* isolate, Handle<Object> microtask); | 151 static void EnqueueMicrotask(Isolate* isolate, Handle<Object> microtask); |
| 179 }; | 152 }; |
| 180 | 153 |
| 181 | 154 |
| 182 class ExecutionAccess; | 155 class ExecutionAccess; |
| 183 | 156 |
| 184 | 157 |
| 185 // StackGuard contains the handling of the limits that are used to limit the | 158 // StackGuard contains the handling of the limits that are used to limit the |
| 186 // number of nested invocations of JavaScript and the stack size used in each | 159 // number of nested invocations of JavaScript and the stack size used in each |
| 187 // invocation. | 160 // invocation. |
| 188 class StackGuard { | 161 class StackGuard V8_FINAL { |
| 189 public: | 162 public: |
| 190 // Pass the address beyond which the stack should not grow. The stack | 163 // Pass the address beyond which the stack should not grow. The stack |
| 191 // is assumed to grow downwards. | 164 // is assumed to grow downwards. |
| 192 void SetStackLimit(uintptr_t limit); | 165 void SetStackLimit(uintptr_t limit); |
| 193 | 166 |
| 194 // Threading support. | 167 // Threading support. |
| 195 char* ArchiveStackGuard(char* to); | 168 char* ArchiveStackGuard(char* to); |
| 196 char* RestoreStackGuard(char* from); | 169 char* RestoreStackGuard(char* from); |
| 197 static int ArchiveSpacePerThread() { return sizeof(ThreadLocal); } | 170 static int ArchiveSpacePerThread() { return sizeof(ThreadLocal); } |
| 198 void FreeThreadResources(); | 171 void FreeThreadResources(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 void DisableInterrupts(); | 256 void DisableInterrupts(); |
| 284 | 257 |
| 285 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 | 258 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 |
| 286 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe); | 259 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe); |
| 287 static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8); | 260 static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8); |
| 288 #else | 261 #else |
| 289 static const uintptr_t kInterruptLimit = 0xfffffffe; | 262 static const uintptr_t kInterruptLimit = 0xfffffffe; |
| 290 static const uintptr_t kIllegalLimit = 0xfffffff8; | 263 static const uintptr_t kIllegalLimit = 0xfffffff8; |
| 291 #endif | 264 #endif |
| 292 | 265 |
| 293 class ThreadLocal { | 266 class ThreadLocal V8_FINAL { |
| 294 public: | 267 public: |
| 295 ThreadLocal() { Clear(); } | 268 ThreadLocal() { Clear(); } |
| 296 // You should hold the ExecutionAccess lock when you call Initialize or | 269 // You should hold the ExecutionAccess lock when you call Initialize or |
| 297 // Clear. | 270 // Clear. |
| 298 void Clear(); | 271 void Clear(); |
| 299 | 272 |
| 300 // Returns true if the heap's stack limits should be set, false if not. | 273 // Returns true if the heap's stack limits should be set, false if not. |
| 301 bool Initialize(Isolate* isolate); | 274 bool Initialize(Isolate* isolate); |
| 302 | 275 |
| 303 // The stack limit is split into a JavaScript and a C++ stack limit. These | 276 // The stack limit is split into a JavaScript and a C++ stack limit. These |
| (...skipping 23 matching lines...) Expand all Loading... |
| 327 Isolate* isolate_; | 300 Isolate* isolate_; |
| 328 ThreadLocal thread_local_; | 301 ThreadLocal thread_local_; |
| 329 | 302 |
| 330 friend class Isolate; | 303 friend class Isolate; |
| 331 friend class StackLimitCheck; | 304 friend class StackLimitCheck; |
| 332 friend class PostponeInterruptsScope; | 305 friend class PostponeInterruptsScope; |
| 333 | 306 |
| 334 DISALLOW_COPY_AND_ASSIGN(StackGuard); | 307 DISALLOW_COPY_AND_ASSIGN(StackGuard); |
| 335 }; | 308 }; |
| 336 | 309 |
| 337 | |
| 338 } } // namespace v8::internal | 310 } } // namespace v8::internal |
| 339 | 311 |
| 340 #endif // V8_EXECUTION_H_ | 312 #endif // V8_EXECUTION_H_ |
| OLD | NEW |