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

Side by Side Diff: src/execution.cc

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 24 matching lines...) Expand all
35 #include "debug.h" 35 #include "debug.h"
36 #include "runtime-profiler.h" 36 #include "runtime-profiler.h"
37 #include "simulator.h" 37 #include "simulator.h"
38 #include "v8threads.h" 38 #include "v8threads.h"
39 #include "vm-state-inl.h" 39 #include "vm-state-inl.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44 44
45 StackGuard::StackGuard()
46 : isolate_(NULL) {
47 }
48
49
50 void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) {
51 ASSERT(isolate_ != NULL);
52 // Ignore attempts to interrupt when interrupts are postponed.
53 if (should_postpone_interrupts(lock)) return;
54 thread_local_.jslimit_ = kInterruptLimit;
55 thread_local_.climit_ = kInterruptLimit;
56 isolate_->heap()->SetStackLimits();
57 }
58
59
60 void StackGuard::reset_limits(const ExecutionAccess& lock) {
61 ASSERT(isolate_ != NULL);
62 thread_local_.jslimit_ = thread_local_.real_jslimit_;
63 thread_local_.climit_ = thread_local_.real_climit_;
64 isolate_->heap()->SetStackLimits();
65 }
66
67
45 static Handle<Object> Invoke(bool construct, 68 static Handle<Object> Invoke(bool construct,
46 Handle<JSFunction> func, 69 Handle<JSFunction> func,
47 Handle<Object> receiver, 70 Handle<Object> receiver,
48 int argc, 71 int argc,
49 Object*** args, 72 Object*** args,
50 bool* has_pending_exception) { 73 bool* has_pending_exception) {
74 Isolate* isolate = func->GetIsolate();
75
51 // Entering JavaScript. 76 // Entering JavaScript.
52 VMState state(JS); 77 VMState state(isolate, JS);
53 78
54 // Placeholder for return value. 79 // Placeholder for return value.
55 MaybeObject* value = reinterpret_cast<Object*>(kZapValue); 80 MaybeObject* value = reinterpret_cast<Object*>(kZapValue);
56 81
57 typedef Object* (*JSEntryFunction)( 82 typedef Object* (*JSEntryFunction)(
58 byte* entry, 83 byte* entry,
59 Object* function, 84 Object* function,
60 Object* receiver, 85 Object* receiver,
61 int argc, 86 int argc,
62 Object*** args); 87 Object*** args);
(...skipping 15 matching lines...) Expand all
78 receiver = Handle<JSObject>(global->global_receiver()); 103 receiver = Handle<JSObject>(global->global_receiver());
79 } 104 }
80 105
81 // Make sure that the global object of the context we're about to 106 // Make sure that the global object of the context we're about to
82 // make the current one is indeed a global object. 107 // make the current one is indeed a global object.
83 ASSERT(func->context()->global()->IsGlobalObject()); 108 ASSERT(func->context()->global()->IsGlobalObject());
84 109
85 { 110 {
86 // Save and restore context around invocation and block the 111 // Save and restore context around invocation and block the
87 // allocation of handles without explicit handle scopes. 112 // allocation of handles without explicit handle scopes.
88 SaveContext save; 113 SaveContext save(isolate);
89 NoHandleAllocation na; 114 NoHandleAllocation na;
90 JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); 115 JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry());
91 116
92 // Call the function through the right JS entry stub. 117 // Call the function through the right JS entry stub.
93 byte* entry_address = func->code()->entry(); 118 byte* entry_address = func->code()->entry();
94 JSFunction* function = *func; 119 JSFunction* function = *func;
95 Object* receiver_pointer = *receiver; 120 Object* receiver_pointer = *receiver;
96 value = CALL_GENERATED_CODE(entry, entry_address, function, 121 value = CALL_GENERATED_CODE(entry, entry_address, function,
97 receiver_pointer, argc, args); 122 receiver_pointer, argc, args);
98 } 123 }
99 124
100 #ifdef DEBUG 125 #ifdef DEBUG
101 value->Verify(); 126 value->Verify();
102 #endif 127 #endif
103 128
104 // Update the pending exception flag and return the value. 129 // Update the pending exception flag and return the value.
105 *has_pending_exception = value->IsException(); 130 *has_pending_exception = value->IsException();
106 ASSERT(*has_pending_exception == Top::has_pending_exception()); 131 ASSERT(*has_pending_exception == Isolate::Current()->has_pending_exception());
107 if (*has_pending_exception) { 132 if (*has_pending_exception) {
108 Top::ReportPendingMessages(); 133 isolate->ReportPendingMessages();
109 if (Top::pending_exception() == Failure::OutOfMemoryException()) { 134 if (isolate->pending_exception() == Failure::OutOfMemoryException()) {
110 if (!HandleScopeImplementer::instance()->ignore_out_of_memory()) { 135 if (!isolate->handle_scope_implementer()->ignore_out_of_memory()) {
111 V8::FatalProcessOutOfMemory("JS", true); 136 V8::FatalProcessOutOfMemory("JS", true);
112 } 137 }
113 } 138 }
114 return Handle<Object>(); 139 return Handle<Object>();
115 } else { 140 } else {
116 Top::clear_pending_message(); 141 isolate->clear_pending_message();
117 } 142 }
118 143
119 return Handle<Object>(value->ToObjectUnchecked()); 144 return Handle<Object>(value->ToObjectUnchecked(), isolate);
120 } 145 }
121 146
122 147
123 Handle<Object> Execution::Call(Handle<JSFunction> func, 148 Handle<Object> Execution::Call(Handle<JSFunction> func,
124 Handle<Object> receiver, 149 Handle<Object> receiver,
125 int argc, 150 int argc,
126 Object*** args, 151 Object*** args,
127 bool* pending_exception) { 152 bool* pending_exception) {
128 return Invoke(false, func, receiver, argc, args, pending_exception); 153 return Invoke(false, func, receiver, argc, args, pending_exception);
129 } 154 }
130 155
131 156
132 Handle<Object> Execution::New(Handle<JSFunction> func, int argc, 157 Handle<Object> Execution::New(Handle<JSFunction> func, int argc,
133 Object*** args, bool* pending_exception) { 158 Object*** args, bool* pending_exception) {
134 return Invoke(true, func, Top::global(), argc, args, pending_exception); 159 return Invoke(true, func, Isolate::Current()->global(), argc, args,
160 pending_exception);
135 } 161 }
136 162
137 163
138 Handle<Object> Execution::TryCall(Handle<JSFunction> func, 164 Handle<Object> Execution::TryCall(Handle<JSFunction> func,
139 Handle<Object> receiver, 165 Handle<Object> receiver,
140 int argc, 166 int argc,
141 Object*** args, 167 Object*** args,
142 bool* caught_exception) { 168 bool* caught_exception) {
143 // Enter a try-block while executing the JavaScript code. To avoid 169 // Enter a try-block while executing the JavaScript code. To avoid
144 // duplicate error printing it must be non-verbose. Also, to avoid 170 // duplicate error printing it must be non-verbose. Also, to avoid
145 // creating message objects during stack overflow we shouldn't 171 // creating message objects during stack overflow we shouldn't
146 // capture messages. 172 // capture messages.
147 v8::TryCatch catcher; 173 v8::TryCatch catcher;
148 catcher.SetVerbose(false); 174 catcher.SetVerbose(false);
149 catcher.SetCaptureMessage(false); 175 catcher.SetCaptureMessage(false);
150 176
151 Handle<Object> result = Invoke(false, func, receiver, argc, args, 177 Handle<Object> result = Invoke(false, func, receiver, argc, args,
152 caught_exception); 178 caught_exception);
153 179
154 if (*caught_exception) { 180 if (*caught_exception) {
155 ASSERT(catcher.HasCaught()); 181 ASSERT(catcher.HasCaught());
156 ASSERT(Top::has_pending_exception()); 182 Isolate* isolate = Isolate::Current();
157 ASSERT(Top::external_caught_exception()); 183 ASSERT(isolate->has_pending_exception());
158 if (Top::pending_exception() == Heap::termination_exception()) { 184 ASSERT(isolate->external_caught_exception());
159 result = Factory::termination_exception(); 185 if (isolate->pending_exception() ==
186 isolate->heap()->termination_exception()) {
187 result = isolate->factory()->termination_exception();
160 } else { 188 } else {
161 result = v8::Utils::OpenHandle(*catcher.Exception()); 189 result = v8::Utils::OpenHandle(*catcher.Exception());
162 } 190 }
163 Top::OptionalRescheduleException(true); 191 isolate->OptionalRescheduleException(true);
164 } 192 }
165 193
166 ASSERT(!Top::has_pending_exception()); 194 ASSERT(!Isolate::Current()->has_pending_exception());
167 ASSERT(!Top::external_caught_exception()); 195 ASSERT(!Isolate::Current()->external_caught_exception());
168 return result; 196 return result;
169 } 197 }
170 198
171 199
172 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { 200 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
173 ASSERT(!object->IsJSFunction()); 201 ASSERT(!object->IsJSFunction());
174 202
175 // If you return a function from here, it will be called when an 203 // If you return a function from here, it will be called when an
176 // attempt is made to call the given object as a function. 204 // attempt is made to call the given object as a function.
177 205
178 // Regular expressions can be called as functions in both Firefox 206 // Regular expressions can be called as functions in both Firefox
179 // and Safari so we allow it too. 207 // and Safari so we allow it too.
180 if (object->IsJSRegExp()) { 208 if (object->IsJSRegExp()) {
181 Handle<String> exec = Factory::exec_symbol(); 209 Handle<String> exec = FACTORY->exec_symbol();
182 // TODO(lrn): Bug 617. We should use the default function here, not the 210 // TODO(lrn): Bug 617. We should use the default function here, not the
183 // one on the RegExp object. 211 // one on the RegExp object.
184 Object* exec_function; 212 Object* exec_function;
185 { MaybeObject* maybe_exec_function = object->GetProperty(*exec); 213 { MaybeObject* maybe_exec_function = object->GetProperty(*exec);
186 // This can lose an exception, but the alternative is to put a failure 214 // This can lose an exception, but the alternative is to put a failure
187 // object in a handle, which is not GC safe. 215 // object in a handle, which is not GC safe.
188 if (!maybe_exec_function->ToObject(&exec_function)) { 216 if (!maybe_exec_function->ToObject(&exec_function)) {
189 return Factory::undefined_value(); 217 return FACTORY->undefined_value();
190 } 218 }
191 } 219 }
192 return Handle<Object>(exec_function); 220 return Handle<Object>(exec_function);
193 } 221 }
194 222
195 // Objects created through the API can have an instance-call handler 223 // Objects created through the API can have an instance-call handler
196 // that should be used when calling the object as a function. 224 // that should be used when calling the object as a function.
197 if (object->IsHeapObject() && 225 if (object->IsHeapObject() &&
198 HeapObject::cast(*object)->map()->has_instance_call_handler()) { 226 HeapObject::cast(*object)->map()->has_instance_call_handler()) {
199 return Handle<JSFunction>( 227 return Handle<JSFunction>(
200 Top::global_context()->call_as_function_delegate()); 228 Isolate::Current()->global_context()->call_as_function_delegate());
201 } 229 }
202 230
203 return Factory::undefined_value(); 231 return FACTORY->undefined_value();
204 } 232 }
205 233
206 234
207 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) { 235 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) {
208 ASSERT(!object->IsJSFunction()); 236 ASSERT(!object->IsJSFunction());
209 237
210 // If you return a function from here, it will be called when an 238 // If you return a function from here, it will be called when an
211 // attempt is made to call the given object as a constructor. 239 // attempt is made to call the given object as a constructor.
212 240
213 // Objects created through the API can have an instance-call handler 241 // Objects created through the API can have an instance-call handler
214 // that should be used when calling the object as a function. 242 // that should be used when calling the object as a function.
215 if (object->IsHeapObject() && 243 if (object->IsHeapObject() &&
216 HeapObject::cast(*object)->map()->has_instance_call_handler()) { 244 HeapObject::cast(*object)->map()->has_instance_call_handler()) {
217 return Handle<JSFunction>( 245 return Handle<JSFunction>(
218 Top::global_context()->call_as_constructor_delegate()); 246 Isolate::Current()->global_context()->call_as_constructor_delegate());
219 } 247 }
220 248
221 return Factory::undefined_value(); 249 return FACTORY->undefined_value();
222 } 250 }
223 251
224 252
225 // Static state for stack guards.
226 StackGuard::ThreadLocal StackGuard::thread_local_;
227
228
229 bool StackGuard::IsStackOverflow() { 253 bool StackGuard::IsStackOverflow() {
230 ExecutionAccess access; 254 ExecutionAccess access(isolate_);
231 return (thread_local_.jslimit_ != kInterruptLimit && 255 return (thread_local_.jslimit_ != kInterruptLimit &&
232 thread_local_.climit_ != kInterruptLimit); 256 thread_local_.climit_ != kInterruptLimit);
233 } 257 }
234 258
235 259
236 void StackGuard::EnableInterrupts() { 260 void StackGuard::EnableInterrupts() {
237 ExecutionAccess access; 261 ExecutionAccess access(isolate_);
238 if (has_pending_interrupts(access)) { 262 if (has_pending_interrupts(access)) {
239 set_interrupt_limits(access); 263 set_interrupt_limits(access);
240 } 264 }
241 } 265 }
242 266
243 267
244 void StackGuard::SetStackLimit(uintptr_t limit) { 268 void StackGuard::SetStackLimit(uintptr_t limit) {
245 ExecutionAccess access; 269 ExecutionAccess access(isolate_);
246 // If the current limits are special (eg due to a pending interrupt) then 270 // If the current limits are special (eg due to a pending interrupt) then
247 // leave them alone. 271 // leave them alone.
248 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit); 272 uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(limit);
249 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) { 273 if (thread_local_.jslimit_ == thread_local_.real_jslimit_) {
250 thread_local_.jslimit_ = jslimit; 274 thread_local_.jslimit_ = jslimit;
251 } 275 }
252 if (thread_local_.climit_ == thread_local_.real_climit_) { 276 if (thread_local_.climit_ == thread_local_.real_climit_) {
253 thread_local_.climit_ = limit; 277 thread_local_.climit_ = limit;
254 } 278 }
255 thread_local_.real_climit_ = limit; 279 thread_local_.real_climit_ = limit;
256 thread_local_.real_jslimit_ = jslimit; 280 thread_local_.real_jslimit_ = jslimit;
257 } 281 }
258 282
259 283
260 void StackGuard::DisableInterrupts() { 284 void StackGuard::DisableInterrupts() {
261 ExecutionAccess access; 285 ExecutionAccess access(isolate_);
262 reset_limits(access); 286 reset_limits(access);
263 } 287 }
264 288
265 289
266 bool StackGuard::IsInterrupted() { 290 bool StackGuard::IsInterrupted() {
267 ExecutionAccess access; 291 ExecutionAccess access(isolate_);
268 return (thread_local_.interrupt_flags_ & INTERRUPT) != 0; 292 return (thread_local_.interrupt_flags_ & INTERRUPT) != 0;
269 } 293 }
270 294
271 295
272 void StackGuard::Interrupt() { 296 void StackGuard::Interrupt() {
273 ExecutionAccess access; 297 ExecutionAccess access(isolate_);
274 thread_local_.interrupt_flags_ |= INTERRUPT; 298 thread_local_.interrupt_flags_ |= INTERRUPT;
275 set_interrupt_limits(access); 299 set_interrupt_limits(access);
276 } 300 }
277 301
278 302
279 bool StackGuard::IsPreempted() { 303 bool StackGuard::IsPreempted() {
280 ExecutionAccess access; 304 ExecutionAccess access(isolate_);
281 return thread_local_.interrupt_flags_ & PREEMPT; 305 return thread_local_.interrupt_flags_ & PREEMPT;
282 } 306 }
283 307
284 308
285 void StackGuard::Preempt() { 309 void StackGuard::Preempt() {
286 ExecutionAccess access; 310 ExecutionAccess access(isolate_);
287 thread_local_.interrupt_flags_ |= PREEMPT; 311 thread_local_.interrupt_flags_ |= PREEMPT;
288 set_interrupt_limits(access); 312 set_interrupt_limits(access);
289 } 313 }
290 314
291 315
292 bool StackGuard::IsTerminateExecution() { 316 bool StackGuard::IsTerminateExecution() {
293 ExecutionAccess access; 317 ExecutionAccess access(isolate_);
294 return (thread_local_.interrupt_flags_ & TERMINATE) != 0; 318 return (thread_local_.interrupt_flags_ & TERMINATE) != 0;
295 } 319 }
296 320
297 321
298 void StackGuard::TerminateExecution() { 322 void StackGuard::TerminateExecution() {
299 ExecutionAccess access; 323 ExecutionAccess access(isolate_);
300 thread_local_.interrupt_flags_ |= TERMINATE; 324 thread_local_.interrupt_flags_ |= TERMINATE;
301 set_interrupt_limits(access); 325 set_interrupt_limits(access);
302 } 326 }
303 327
304 328
305 bool StackGuard::IsRuntimeProfilerTick() { 329 bool StackGuard::IsRuntimeProfilerTick() {
306 ExecutionAccess access; 330 ExecutionAccess access(isolate_);
307 return (thread_local_.interrupt_flags_ & RUNTIME_PROFILER_TICK) != 0; 331 return (thread_local_.interrupt_flags_ & RUNTIME_PROFILER_TICK) != 0;
308 } 332 }
309 333
310 334
311 void StackGuard::RequestRuntimeProfilerTick() { 335 void StackGuard::RequestRuntimeProfilerTick() {
312 // Ignore calls if we're not optimizing or if we can't get the lock. 336 // Ignore calls if we're not optimizing or if we can't get the lock.
313 if (FLAG_opt && ExecutionAccess::TryLock()) { 337 if (FLAG_opt && ExecutionAccess::TryLock(isolate_)) {
314 thread_local_.interrupt_flags_ |= RUNTIME_PROFILER_TICK; 338 thread_local_.interrupt_flags_ |= RUNTIME_PROFILER_TICK;
315 if (thread_local_.postpone_interrupts_nesting_ == 0) { 339 if (thread_local_.postpone_interrupts_nesting_ == 0) {
316 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit; 340 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit;
317 Heap::SetStackLimits(); 341 isolate_->heap()->SetStackLimits();
318 } 342 }
319 ExecutionAccess::Unlock(); 343 ExecutionAccess::Unlock(isolate_);
320 } 344 }
321 } 345 }
322 346
323 347
324 bool StackGuard::IsGCRequest() { 348 bool StackGuard::IsGCRequest() {
325 ExecutionAccess access; 349 ExecutionAccess access(isolate_);
326 return (thread_local_.interrupt_flags_ & GC_REQUEST) != 0; 350 return (thread_local_.interrupt_flags_ & GC_REQUEST) != 0;
327 } 351 }
328 352
329 353
330 void StackGuard::RequestGC() { 354 void StackGuard::RequestGC() {
331 ExecutionAccess access; 355 ExecutionAccess access(isolate_);
332 thread_local_.interrupt_flags_ |= GC_REQUEST; 356 thread_local_.interrupt_flags_ |= GC_REQUEST;
333 if (thread_local_.postpone_interrupts_nesting_ == 0) { 357 if (thread_local_.postpone_interrupts_nesting_ == 0) {
334 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit; 358 thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit;
335 Heap::SetStackLimits(); 359 isolate_->heap()->SetStackLimits();
336 } 360 }
337 } 361 }
338 362
339 363
340 #ifdef ENABLE_DEBUGGER_SUPPORT 364 #ifdef ENABLE_DEBUGGER_SUPPORT
341 bool StackGuard::IsDebugBreak() { 365 bool StackGuard::IsDebugBreak() {
342 ExecutionAccess access; 366 ExecutionAccess access(isolate_);
343 return thread_local_.interrupt_flags_ & DEBUGBREAK; 367 return thread_local_.interrupt_flags_ & DEBUGBREAK;
344 } 368 }
345 369
346 370
347 void StackGuard::DebugBreak() { 371 void StackGuard::DebugBreak() {
348 ExecutionAccess access; 372 ExecutionAccess access(isolate_);
349 thread_local_.interrupt_flags_ |= DEBUGBREAK; 373 thread_local_.interrupt_flags_ |= DEBUGBREAK;
350 set_interrupt_limits(access); 374 set_interrupt_limits(access);
351 } 375 }
352 376
353 377
354 bool StackGuard::IsDebugCommand() { 378 bool StackGuard::IsDebugCommand() {
355 ExecutionAccess access; 379 ExecutionAccess access(isolate_);
356 return thread_local_.interrupt_flags_ & DEBUGCOMMAND; 380 return thread_local_.interrupt_flags_ & DEBUGCOMMAND;
357 } 381 }
358 382
359 383
360 void StackGuard::DebugCommand() { 384 void StackGuard::DebugCommand() {
361 if (FLAG_debugger_auto_break) { 385 if (FLAG_debugger_auto_break) {
362 ExecutionAccess access; 386 ExecutionAccess access(isolate_);
363 thread_local_.interrupt_flags_ |= DEBUGCOMMAND; 387 thread_local_.interrupt_flags_ |= DEBUGCOMMAND;
364 set_interrupt_limits(access); 388 set_interrupt_limits(access);
365 } 389 }
366 } 390 }
367 #endif 391 #endif
368 392
369 void StackGuard::Continue(InterruptFlag after_what) { 393 void StackGuard::Continue(InterruptFlag after_what) {
370 ExecutionAccess access; 394 ExecutionAccess access(isolate_);
371 thread_local_.interrupt_flags_ &= ~static_cast<int>(after_what); 395 thread_local_.interrupt_flags_ &= ~static_cast<int>(after_what);
372 if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) { 396 if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) {
373 reset_limits(access); 397 reset_limits(access);
374 } 398 }
375 } 399 }
376 400
377 401
378 int StackGuard::ArchiveSpacePerThread() {
379 return sizeof(ThreadLocal);
380 }
381
382
383 char* StackGuard::ArchiveStackGuard(char* to) { 402 char* StackGuard::ArchiveStackGuard(char* to) {
384 ExecutionAccess access; 403 ExecutionAccess access(isolate_);
385 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); 404 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal));
386 ThreadLocal blank; 405 ThreadLocal blank;
406
407 // Set the stack limits using the old thread_local_.
408 // TODO(isolates): This was the old semantics of constructing a ThreadLocal
409 // (as the ctor called SetStackLimits, which looked at the
410 // current thread_local_ from StackGuard)-- but is this
411 // really what was intended?
412 isolate_->heap()->SetStackLimits();
387 thread_local_ = blank; 413 thread_local_ = blank;
414
388 return to + sizeof(ThreadLocal); 415 return to + sizeof(ThreadLocal);
389 } 416 }
390 417
391 418
392 char* StackGuard::RestoreStackGuard(char* from) { 419 char* StackGuard::RestoreStackGuard(char* from) {
393 ExecutionAccess access; 420 ExecutionAccess access(isolate_);
394 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); 421 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal));
395 Heap::SetStackLimits(); 422 isolate_->heap()->SetStackLimits();
396 return from + sizeof(ThreadLocal); 423 return from + sizeof(ThreadLocal);
397 } 424 }
398 425
399 426
400 static internal::Thread::LocalStorageKey stack_limit_key =
401 internal::Thread::CreateThreadLocalKey();
402
403
404 void StackGuard::FreeThreadResources() { 427 void StackGuard::FreeThreadResources() {
405 Thread::SetThreadLocal( 428 Isolate::CurrentPerIsolateThreadData()->set_stack_limit(
406 stack_limit_key, 429 thread_local_.real_climit_);
407 reinterpret_cast<void*>(thread_local_.real_climit_));
408 } 430 }
409 431
410 432
411 void StackGuard::ThreadLocal::Clear() { 433 void StackGuard::ThreadLocal::Clear() {
412 real_jslimit_ = kIllegalLimit; 434 real_jslimit_ = kIllegalLimit;
413 jslimit_ = kIllegalLimit; 435 jslimit_ = kIllegalLimit;
414 real_climit_ = kIllegalLimit; 436 real_climit_ = kIllegalLimit;
415 climit_ = kIllegalLimit; 437 climit_ = kIllegalLimit;
416 nesting_ = 0; 438 nesting_ = 0;
417 postpone_interrupts_nesting_ = 0; 439 postpone_interrupts_nesting_ = 0;
418 interrupt_flags_ = 0; 440 interrupt_flags_ = 0;
419 Heap::SetStackLimits();
420 } 441 }
421 442
422 443
423 void StackGuard::ThreadLocal::Initialize() { 444 bool StackGuard::ThreadLocal::Initialize() {
445 bool should_set_stack_limits = false;
424 if (real_climit_ == kIllegalLimit) { 446 if (real_climit_ == kIllegalLimit) {
425 // Takes the address of the limit variable in order to find out where 447 // Takes the address of the limit variable in order to find out where
426 // the top of stack is right now. 448 // the top of stack is right now.
427 const uintptr_t kLimitSize = FLAG_stack_size * KB; 449 const uintptr_t kLimitSize = FLAG_stack_size * KB;
428 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize; 450 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize;
429 ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize); 451 ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize);
430 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); 452 real_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit);
431 jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); 453 jslimit_ = SimulatorStack::JsLimitFromCLimit(limit);
432 real_climit_ = limit; 454 real_climit_ = limit;
433 climit_ = limit; 455 climit_ = limit;
434 Heap::SetStackLimits(); 456 should_set_stack_limits = true;
435 } 457 }
436 nesting_ = 0; 458 nesting_ = 0;
437 postpone_interrupts_nesting_ = 0; 459 postpone_interrupts_nesting_ = 0;
438 interrupt_flags_ = 0; 460 interrupt_flags_ = 0;
461 return should_set_stack_limits;
439 } 462 }
440 463
441 464
442 void StackGuard::ClearThread(const ExecutionAccess& lock) { 465 void StackGuard::ClearThread(const ExecutionAccess& lock) {
443 thread_local_.Clear(); 466 thread_local_.Clear();
467 isolate_->heap()->SetStackLimits();
444 } 468 }
445 469
446 470
447 void StackGuard::InitThread(const ExecutionAccess& lock) { 471 void StackGuard::InitThread(const ExecutionAccess& lock) {
448 thread_local_.Initialize(); 472 if (thread_local_.Initialize()) isolate_->heap()->SetStackLimits();
449 void* stored_limit = Thread::GetThreadLocal(stack_limit_key); 473 uintptr_t stored_limit =
474 Isolate::CurrentPerIsolateThreadData()->stack_limit();
450 // You should hold the ExecutionAccess lock when you call this. 475 // You should hold the ExecutionAccess lock when you call this.
451 if (stored_limit != NULL) { 476 if (stored_limit != 0) {
452 StackGuard::SetStackLimit(reinterpret_cast<intptr_t>(stored_limit)); 477 StackGuard::SetStackLimit(stored_limit);
453 } 478 }
454 } 479 }
455 480
456 481
457 // --- C a l l s t o n a t i v e s --- 482 // --- C a l l s t o n a t i v e s ---
458 483
459 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ 484 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \
460 do { \ 485 do { \
461 Object** args[argc] = argv; \ 486 Object** args[argc] = argv; \
462 ASSERT(has_pending_exception != NULL); \ 487 ASSERT(has_pending_exception != NULL); \
463 return Call(Top::name##_fun(), Top::builtins(), argc, args, \ 488 return Call(Isolate::Current()->name##_fun(), \
464 has_pending_exception); \ 489 Isolate::Current()->js_builtins_object(), argc, args, \
490 has_pending_exception); \
465 } while (false) 491 } while (false)
466 492
467 493
468 Handle<Object> Execution::ToBoolean(Handle<Object> obj) { 494 Handle<Object> Execution::ToBoolean(Handle<Object> obj) {
469 // See the similar code in runtime.js:ToBoolean. 495 // See the similar code in runtime.js:ToBoolean.
470 if (obj->IsBoolean()) return obj; 496 if (obj->IsBoolean()) return obj;
471 bool result = true; 497 bool result = true;
472 if (obj->IsString()) { 498 if (obj->IsString()) {
473 result = Handle<String>::cast(obj)->length() != 0; 499 result = Handle<String>::cast(obj)->length() != 0;
474 } else if (obj->IsNull() || obj->IsUndefined()) { 500 } else if (obj->IsNull() || obj->IsUndefined()) {
475 result = false; 501 result = false;
476 } else if (obj->IsNumber()) { 502 } else if (obj->IsNumber()) {
477 double value = obj->Number(); 503 double value = obj->Number();
478 result = !((value == 0) || isnan(value)); 504 result = !((value == 0) || isnan(value));
479 } 505 }
480 return Handle<Object>(Heap::ToBoolean(result)); 506 return Handle<Object>(HEAP->ToBoolean(result));
481 } 507 }
482 508
483 509
484 Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) { 510 Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) {
485 RETURN_NATIVE_CALL(to_number, 1, { obj.location() }, exc); 511 RETURN_NATIVE_CALL(to_number, 1, { obj.location() }, exc);
486 } 512 }
487 513
488 514
489 Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) { 515 Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) {
490 RETURN_NATIVE_CALL(to_string, 1, { obj.location() }, exc); 516 RETURN_NATIVE_CALL(to_string, 1, { obj.location() }, exc);
(...skipping 20 matching lines...) Expand all
511 RETURN_NATIVE_CALL(to_uint32, 1, { obj.location() }, exc); 537 RETURN_NATIVE_CALL(to_uint32, 1, { obj.location() }, exc);
512 } 538 }
513 539
514 540
515 Handle<Object> Execution::ToInt32(Handle<Object> obj, bool* exc) { 541 Handle<Object> Execution::ToInt32(Handle<Object> obj, bool* exc) {
516 RETURN_NATIVE_CALL(to_int32, 1, { obj.location() }, exc); 542 RETURN_NATIVE_CALL(to_int32, 1, { obj.location() }, exc);
517 } 543 }
518 544
519 545
520 Handle<Object> Execution::NewDate(double time, bool* exc) { 546 Handle<Object> Execution::NewDate(double time, bool* exc) {
521 Handle<Object> time_obj = Factory::NewNumber(time); 547 Handle<Object> time_obj = FACTORY->NewNumber(time);
522 RETURN_NATIVE_CALL(create_date, 1, { time_obj.location() }, exc); 548 RETURN_NATIVE_CALL(create_date, 1, { time_obj.location() }, exc);
523 } 549 }
524 550
525 551
526 #undef RETURN_NATIVE_CALL 552 #undef RETURN_NATIVE_CALL
527 553
528 554
529 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, 555 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
530 Handle<String> flags, 556 Handle<String> flags,
531 bool* exc) { 557 bool* exc) {
558 Handle<JSFunction> function = Handle<JSFunction>(
559 pattern->GetIsolate()->global_context()->regexp_function());
532 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral( 560 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral(
533 Handle<JSFunction>(Top::global_context()->regexp_function()), 561 function, pattern, flags, exc);
534 pattern,
535 flags,
536 exc);
537 if (*exc) return Handle<JSRegExp>(); 562 if (*exc) return Handle<JSRegExp>();
538 return Handle<JSRegExp>::cast(re_obj); 563 return Handle<JSRegExp>::cast(re_obj);
539 } 564 }
540 565
541 566
542 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { 567 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
543 int int_index = static_cast<int>(index); 568 int int_index = static_cast<int>(index);
544 if (int_index < 0 || int_index >= string->length()) { 569 if (int_index < 0 || int_index >= string->length()) {
545 return Factory::undefined_value(); 570 return FACTORY->undefined_value();
546 } 571 }
547 572
548 Handle<Object> char_at = 573 Handle<Object> char_at =
549 GetProperty(Top::builtins(), Factory::char_at_symbol()); 574 GetProperty(Isolate::Current()->js_builtins_object(),
575 FACTORY->char_at_symbol());
550 if (!char_at->IsJSFunction()) { 576 if (!char_at->IsJSFunction()) {
551 return Factory::undefined_value(); 577 return FACTORY->undefined_value();
552 } 578 }
553 579
554 bool caught_exception; 580 bool caught_exception;
555 Handle<Object> index_object = Factory::NewNumberFromInt(int_index); 581 Handle<Object> index_object = FACTORY->NewNumberFromInt(int_index);
556 Object** index_arg[] = { index_object.location() }; 582 Object** index_arg[] = { index_object.location() };
557 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at), 583 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at),
558 string, 584 string,
559 ARRAY_SIZE(index_arg), 585 ARRAY_SIZE(index_arg),
560 index_arg, 586 index_arg,
561 &caught_exception); 587 &caught_exception);
562 if (caught_exception) { 588 if (caught_exception) {
563 return Factory::undefined_value(); 589 return FACTORY->undefined_value();
564 } 590 }
565 return result; 591 return result;
566 } 592 }
567 593
568 594
569 Handle<JSFunction> Execution::InstantiateFunction( 595 Handle<JSFunction> Execution::InstantiateFunction(
570 Handle<FunctionTemplateInfo> data, bool* exc) { 596 Handle<FunctionTemplateInfo> data, bool* exc) {
571 // Fast case: see if the function has already been instantiated 597 // Fast case: see if the function has already been instantiated
572 int serial_number = Smi::cast(data->serial_number())->value(); 598 int serial_number = Smi::cast(data->serial_number())->value();
573 Object* elm = Top::global_context()->function_cache()-> 599 Object* elm =
574 GetElementNoExceptionThrown(serial_number); 600 Isolate::Current()->global_context()->function_cache()->
601 GetElementNoExceptionThrown(serial_number);
575 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); 602 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
576 // The function has not yet been instantiated in this context; do it. 603 // The function has not yet been instantiated in this context; do it.
577 Object** args[1] = { Handle<Object>::cast(data).location() }; 604 Object** args[1] = { Handle<Object>::cast(data).location() };
578 Handle<Object> result = 605 Handle<Object> result =
579 Call(Top::instantiate_fun(), Top::builtins(), 1, args, exc); 606 Call(Isolate::Current()->instantiate_fun(),
607 Isolate::Current()->js_builtins_object(), 1, args, exc);
580 if (*exc) return Handle<JSFunction>::null(); 608 if (*exc) return Handle<JSFunction>::null();
581 return Handle<JSFunction>::cast(result); 609 return Handle<JSFunction>::cast(result);
582 } 610 }
583 611
584 612
585 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, 613 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data,
586 bool* exc) { 614 bool* exc) {
587 if (data->property_list()->IsUndefined() && 615 if (data->property_list()->IsUndefined() &&
588 !data->constructor()->IsUndefined()) { 616 !data->constructor()->IsUndefined()) {
589 // Initialization to make gcc happy. 617 // Initialization to make gcc happy.
590 Object* result = NULL; 618 Object* result = NULL;
591 { 619 {
592 HandleScope scope; 620 HandleScope scope;
593 Handle<FunctionTemplateInfo> cons_template = 621 Handle<FunctionTemplateInfo> cons_template =
594 Handle<FunctionTemplateInfo>( 622 Handle<FunctionTemplateInfo>(
595 FunctionTemplateInfo::cast(data->constructor())); 623 FunctionTemplateInfo::cast(data->constructor()));
596 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc); 624 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc);
597 if (*exc) return Handle<JSObject>::null(); 625 if (*exc) return Handle<JSObject>::null();
598 Handle<Object> value = New(cons, 0, NULL, exc); 626 Handle<Object> value = New(cons, 0, NULL, exc);
599 if (*exc) return Handle<JSObject>::null(); 627 if (*exc) return Handle<JSObject>::null();
600 result = *value; 628 result = *value;
601 } 629 }
602 ASSERT(!*exc); 630 ASSERT(!*exc);
603 return Handle<JSObject>(JSObject::cast(result)); 631 return Handle<JSObject>(JSObject::cast(result));
604 } else { 632 } else {
605 Object** args[1] = { Handle<Object>::cast(data).location() }; 633 Object** args[1] = { Handle<Object>::cast(data).location() };
606 Handle<Object> result = 634 Handle<Object> result =
607 Call(Top::instantiate_fun(), Top::builtins(), 1, args, exc); 635 Call(Isolate::Current()->instantiate_fun(),
636 Isolate::Current()->js_builtins_object(), 1, args, exc);
608 if (*exc) return Handle<JSObject>::null(); 637 if (*exc) return Handle<JSObject>::null();
609 return Handle<JSObject>::cast(result); 638 return Handle<JSObject>::cast(result);
610 } 639 }
611 } 640 }
612 641
613 642
614 void Execution::ConfigureInstance(Handle<Object> instance, 643 void Execution::ConfigureInstance(Handle<Object> instance,
615 Handle<Object> instance_template, 644 Handle<Object> instance_template,
616 bool* exc) { 645 bool* exc) {
617 Object** args[2] = { instance.location(), instance_template.location() }; 646 Object** args[2] = { instance.location(), instance_template.location() };
618 Execution::Call(Top::configure_instance_fun(), Top::builtins(), 2, args, exc); 647 Execution::Call(Isolate::Current()->configure_instance_fun(),
648 Isolate::Current()->js_builtins_object(), 2, args, exc);
619 } 649 }
620 650
621 651
622 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, 652 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
623 Handle<JSFunction> fun, 653 Handle<JSFunction> fun,
624 Handle<Object> pos, 654 Handle<Object> pos,
625 Handle<Object> is_global) { 655 Handle<Object> is_global) {
626 const int argc = 4; 656 const int argc = 4;
627 Object** args[argc] = { recv.location(), 657 Object** args[argc] = { recv.location(),
628 Handle<Object>::cast(fun).location(), 658 Handle<Object>::cast(fun).location(),
629 pos.location(), 659 pos.location(),
630 is_global.location() }; 660 is_global.location() };
631 bool caught_exception = false; 661 bool caught_exception = false;
632 Handle<Object> result = TryCall(Top::get_stack_trace_line_fun(), 662 Handle<Object> result =
633 Top::builtins(), argc, args, 663 TryCall(Isolate::Current()->get_stack_trace_line_fun(),
634 &caught_exception); 664 Isolate::Current()->js_builtins_object(), argc, args,
635 if (caught_exception || !result->IsString()) return Factory::empty_symbol(); 665 &caught_exception);
666 if (caught_exception || !result->IsString()) return FACTORY->empty_symbol();
636 return Handle<String>::cast(result); 667 return Handle<String>::cast(result);
637 } 668 }
638 669
639 670
640 static Object* RuntimePreempt() { 671 static Object* RuntimePreempt() {
672 Isolate* isolate = Isolate::Current();
673
641 // Clear the preempt request flag. 674 // Clear the preempt request flag.
642 StackGuard::Continue(PREEMPT); 675 isolate->stack_guard()->Continue(PREEMPT);
643 676
644 ContextSwitcher::PreemptionReceived(); 677 ContextSwitcher::PreemptionReceived();
645 678
646 #ifdef ENABLE_DEBUGGER_SUPPORT 679 #ifdef ENABLE_DEBUGGER_SUPPORT
647 if (Debug::InDebugger()) { 680 if (isolate->debug()->InDebugger()) {
648 // If currently in the debugger don't do any actual preemption but record 681 // If currently in the debugger don't do any actual preemption but record
649 // that preemption occoured while in the debugger. 682 // that preemption occoured while in the debugger.
650 Debug::PreemptionWhileInDebugger(); 683 isolate->debug()->PreemptionWhileInDebugger();
651 } else { 684 } else {
652 // Perform preemption. 685 // Perform preemption.
653 v8::Unlocker unlocker; 686 v8::Unlocker unlocker;
654 Thread::YieldCPU(); 687 Thread::YieldCPU();
655 } 688 }
656 #else 689 #else
657 // Perform preemption. 690 { // NOLINT
658 v8::Unlocker unlocker; 691 // Perform preemption.
659 Thread::YieldCPU(); 692 v8::Unlocker unlocker;
693 Thread::YieldCPU();
694 }
660 #endif 695 #endif
661 696
662 return Heap::undefined_value(); 697 return isolate->heap()->undefined_value();
663 } 698 }
664 699
665 700
666 #ifdef ENABLE_DEBUGGER_SUPPORT 701 #ifdef ENABLE_DEBUGGER_SUPPORT
667 Object* Execution::DebugBreakHelper() { 702 Object* Execution::DebugBreakHelper() {
703 Isolate* isolate = Isolate::Current();
704
668 // Just continue if breaks are disabled. 705 // Just continue if breaks are disabled.
669 if (Debug::disable_break()) { 706 if (isolate->debug()->disable_break()) {
670 return Heap::undefined_value(); 707 return isolate->heap()->undefined_value();
671 } 708 }
672 709
673 // Ignore debug break during bootstrapping. 710 // Ignore debug break during bootstrapping.
674 if (Bootstrapper::IsActive()) { 711 if (isolate->bootstrapper()->IsActive()) {
675 return Heap::undefined_value(); 712 return isolate->heap()->undefined_value();
676 } 713 }
677 714
678 { 715 {
679 JavaScriptFrameIterator it; 716 JavaScriptFrameIterator it;
680 ASSERT(!it.done()); 717 ASSERT(!it.done());
681 Object* fun = it.frame()->function(); 718 Object* fun = it.frame()->function();
682 if (fun && fun->IsJSFunction()) { 719 if (fun && fun->IsJSFunction()) {
683 // Don't stop in builtin functions. 720 // Don't stop in builtin functions.
684 if (JSFunction::cast(fun)->IsBuiltin()) { 721 if (JSFunction::cast(fun)->IsBuiltin()) {
685 return Heap::undefined_value(); 722 return isolate->heap()->undefined_value();
686 } 723 }
687 GlobalObject* global = JSFunction::cast(fun)->context()->global(); 724 GlobalObject* global = JSFunction::cast(fun)->context()->global();
688 // Don't stop in debugger functions. 725 // Don't stop in debugger functions.
689 if (Debug::IsDebugGlobal(global)) { 726 if (isolate->debug()->IsDebugGlobal(global)) {
690 return Heap::undefined_value(); 727 return isolate->heap()->undefined_value();
691 } 728 }
692 } 729 }
693 } 730 }
694 731
695 // Collect the break state before clearing the flags. 732 // Collect the break state before clearing the flags.
696 bool debug_command_only = 733 bool debug_command_only =
697 StackGuard::IsDebugCommand() && !StackGuard::IsDebugBreak(); 734 isolate->stack_guard()->IsDebugCommand() &&
735 !isolate->stack_guard()->IsDebugBreak();
698 736
699 // Clear the debug break request flag. 737 // Clear the debug break request flag.
700 StackGuard::Continue(DEBUGBREAK); 738 isolate->stack_guard()->Continue(DEBUGBREAK);
701 739
702 ProcessDebugMesssages(debug_command_only); 740 ProcessDebugMesssages(debug_command_only);
703 741
704 // Return to continue execution. 742 // Return to continue execution.
705 return Heap::undefined_value(); 743 return isolate->heap()->undefined_value();
706 } 744 }
707 745
708 void Execution::ProcessDebugMesssages(bool debug_command_only) { 746 void Execution::ProcessDebugMesssages(bool debug_command_only) {
709 // Clear the debug command request flag. 747 // Clear the debug command request flag.
710 StackGuard::Continue(DEBUGCOMMAND); 748 Isolate::Current()->stack_guard()->Continue(DEBUGCOMMAND);
711 749
712 HandleScope scope; 750 HandleScope scope;
713 // Enter the debugger. Just continue if we fail to enter the debugger. 751 // Enter the debugger. Just continue if we fail to enter the debugger.
714 EnterDebugger debugger; 752 EnterDebugger debugger;
715 if (debugger.FailedToEnter()) { 753 if (debugger.FailedToEnter()) {
716 return; 754 return;
717 } 755 }
718 756
719 // Notify the debug event listeners. Indicate auto continue if the break was 757 // Notify the debug event listeners. Indicate auto continue if the break was
720 // a debug command break. 758 // a debug command break.
721 Debugger::OnDebugBreak(Factory::undefined_value(), debug_command_only); 759 Isolate::Current()->debugger()->OnDebugBreak(FACTORY->undefined_value(),
760 debug_command_only);
722 } 761 }
723 762
724 763
725 #endif 764 #endif
726 765
727 MaybeObject* Execution::HandleStackGuardInterrupt() { 766 MaybeObject* Execution::HandleStackGuardInterrupt() {
728 if (StackGuard::IsGCRequest()) { 767 Isolate* isolate = Isolate::Current();
729 Heap::CollectAllGarbage(false); 768 StackGuard* stack_guard = isolate->stack_guard();
730 StackGuard::Continue(GC_REQUEST); 769
770 if (stack_guard->IsGCRequest()) {
771 isolate->heap()->CollectAllGarbage(false);
772 stack_guard->Continue(GC_REQUEST);
731 } 773 }
732 774
733 Counters::stack_interrupts.Increment(); 775 isolate->counters()->stack_interrupts()->Increment();
734 if (StackGuard::IsRuntimeProfilerTick()) { 776 if (stack_guard->IsRuntimeProfilerTick()) {
735 Counters::runtime_profiler_ticks.Increment(); 777 isolate->counters()->runtime_profiler_ticks()->Increment();
736 StackGuard::Continue(RUNTIME_PROFILER_TICK); 778 stack_guard->Continue(RUNTIME_PROFILER_TICK);
737 RuntimeProfiler::OptimizeNow(); 779 isolate->runtime_profiler()->OptimizeNow();
738 } 780 }
739 #ifdef ENABLE_DEBUGGER_SUPPORT 781 #ifdef ENABLE_DEBUGGER_SUPPORT
740 if (StackGuard::IsDebugBreak() || StackGuard::IsDebugCommand()) { 782 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) {
741 DebugBreakHelper(); 783 DebugBreakHelper();
742 } 784 }
743 #endif 785 #endif
744 if (StackGuard::IsPreempted()) RuntimePreempt(); 786 if (stack_guard->IsPreempted()) RuntimePreempt();
745 if (StackGuard::IsTerminateExecution()) { 787 if (stack_guard->IsTerminateExecution()) {
746 StackGuard::Continue(TERMINATE); 788 stack_guard->Continue(TERMINATE);
747 return Top::TerminateExecution(); 789 return isolate->TerminateExecution();
748 } 790 }
749 if (StackGuard::IsInterrupted()) { 791 if (stack_guard->IsInterrupted()) {
750 StackGuard::Continue(INTERRUPT); 792 stack_guard->Continue(INTERRUPT);
751 return Top::StackOverflow(); 793 return isolate->StackOverflow();
752 } 794 }
753 return Heap::undefined_value(); 795 return isolate->heap()->undefined_value();
754 } 796 }
755 797
756 } } // namespace v8::internal 798 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/extensions/externalize-string-extension.cc » ('j') | src/heap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698