| OLD | NEW |
| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 value = CALL_GENERATED_CODE(entry, entry_address, function, | 118 value = CALL_GENERATED_CODE(entry, entry_address, function, |
| 119 receiver_pointer, argc, args); | 119 receiver_pointer, argc, args); |
| 120 } | 120 } |
| 121 | 121 |
| 122 #ifdef DEBUG | 122 #ifdef DEBUG |
| 123 value->Verify(); | 123 value->Verify(); |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 // Update the pending exception flag and return the value. | 126 // Update the pending exception flag and return the value. |
| 127 *has_pending_exception = value->IsException(); | 127 *has_pending_exception = value->IsException(); |
| 128 ASSERT(*has_pending_exception == Top::has_pending_exception()); | 128 ASSERT(*has_pending_exception == Isolate::Current()->has_pending_exception()); |
| 129 if (*has_pending_exception) { | 129 if (*has_pending_exception) { |
| 130 Top::ReportPendingMessages(); | 130 Isolate::Current()->ReportPendingMessages(); |
| 131 return Handle<Object>(); | 131 return Handle<Object>(); |
| 132 } else { | 132 } else { |
| 133 Top::clear_pending_message(); | 133 Isolate::Current()->clear_pending_message(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 return Handle<Object>(value); | 136 return Handle<Object>(value); |
| 137 } | 137 } |
| 138 | 138 |
| 139 | 139 |
| 140 Handle<Object> Execution::Call(Handle<JSFunction> func, | 140 Handle<Object> Execution::Call(Handle<JSFunction> func, |
| 141 Handle<Object> receiver, | 141 Handle<Object> receiver, |
| 142 int argc, | 142 int argc, |
| 143 Object*** args, | 143 Object*** args, |
| 144 bool* pending_exception) { | 144 bool* pending_exception) { |
| 145 return Invoke(false, func, receiver, argc, args, pending_exception); | 145 return Invoke(false, func, receiver, argc, args, pending_exception); |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 Handle<Object> Execution::New(Handle<JSFunction> func, int argc, | 149 Handle<Object> Execution::New(Handle<JSFunction> func, int argc, |
| 150 Object*** args, bool* pending_exception) { | 150 Object*** args, bool* pending_exception) { |
| 151 return Invoke(true, func, Top::global(), argc, args, pending_exception); | 151 return Invoke(true, func, Isolate::Current()->global(), argc, args, |
| 152 pending_exception); |
| 152 } | 153 } |
| 153 | 154 |
| 154 | 155 |
| 155 Handle<Object> Execution::TryCall(Handle<JSFunction> func, | 156 Handle<Object> Execution::TryCall(Handle<JSFunction> func, |
| 156 Handle<Object> receiver, | 157 Handle<Object> receiver, |
| 157 int argc, | 158 int argc, |
| 158 Object*** args, | 159 Object*** args, |
| 159 bool* caught_exception) { | 160 bool* caught_exception) { |
| 160 // Enter a try-block while executing the JavaScript code. To avoid | 161 // Enter a try-block while executing the JavaScript code. To avoid |
| 161 // duplicate error printing it must be non-verbose. Also, to avoid | 162 // duplicate error printing it must be non-verbose. Also, to avoid |
| 162 // creating message objects during stack overflow we shouldn't | 163 // creating message objects during stack overflow we shouldn't |
| 163 // capture messages. | 164 // capture messages. |
| 164 v8::TryCatch catcher; | 165 v8::TryCatch catcher; |
| 165 catcher.SetVerbose(false); | 166 catcher.SetVerbose(false); |
| 166 catcher.SetCaptureMessage(false); | 167 catcher.SetCaptureMessage(false); |
| 167 | 168 |
| 168 Handle<Object> result = Invoke(false, func, receiver, argc, args, | 169 Handle<Object> result = Invoke(false, func, receiver, argc, args, |
| 169 caught_exception); | 170 caught_exception); |
| 170 | 171 |
| 171 if (*caught_exception) { | 172 if (*caught_exception) { |
| 172 ASSERT(catcher.HasCaught()); | 173 ASSERT(catcher.HasCaught()); |
| 173 ASSERT(Top::has_pending_exception()); | 174 ASSERT(Isolate::Current()->has_pending_exception()); |
| 174 ASSERT(Top::external_caught_exception()); | 175 ASSERT(Isolate::Current()->external_caught_exception()); |
| 175 if (Top::pending_exception() == HEAP->termination_exception()) { | 176 if (Isolate::Current()->pending_exception() == |
| 177 HEAP->termination_exception()) { |
| 176 result = Factory::termination_exception(); | 178 result = Factory::termination_exception(); |
| 177 } else { | 179 } else { |
| 178 result = v8::Utils::OpenHandle(*catcher.Exception()); | 180 result = v8::Utils::OpenHandle(*catcher.Exception()); |
| 179 } | 181 } |
| 180 Top::OptionalRescheduleException(true); | 182 Isolate::Current()->OptionalRescheduleException(true); |
| 181 } | 183 } |
| 182 | 184 |
| 183 ASSERT(!Top::has_pending_exception()); | 185 ASSERT(!Isolate::Current()->has_pending_exception()); |
| 184 ASSERT(!Top::external_caught_exception()); | 186 ASSERT(!Isolate::Current()->external_caught_exception()); |
| 185 return result; | 187 return result; |
| 186 } | 188 } |
| 187 | 189 |
| 188 | 190 |
| 189 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { | 191 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { |
| 190 ASSERT(!object->IsJSFunction()); | 192 ASSERT(!object->IsJSFunction()); |
| 191 | 193 |
| 192 // If you return a function from here, it will be called when an | 194 // If you return a function from here, it will be called when an |
| 193 // attempt is made to call the given object as a function. | 195 // attempt is made to call the given object as a function. |
| 194 | 196 |
| 195 // Regular expressions can be called as functions in both Firefox | 197 // Regular expressions can be called as functions in both Firefox |
| 196 // and Safari so we allow it too. | 198 // and Safari so we allow it too. |
| 197 if (object->IsJSRegExp()) { | 199 if (object->IsJSRegExp()) { |
| 198 Handle<String> exec = Factory::exec_symbol(); | 200 Handle<String> exec = Factory::exec_symbol(); |
| 199 return Handle<Object>(object->GetProperty(*exec)); | 201 return Handle<Object>(object->GetProperty(*exec)); |
| 200 } | 202 } |
| 201 | 203 |
| 202 // Objects created through the API can have an instance-call handler | 204 // Objects created through the API can have an instance-call handler |
| 203 // that should be used when calling the object as a function. | 205 // that should be used when calling the object as a function. |
| 204 if (object->IsHeapObject() && | 206 if (object->IsHeapObject() && |
| 205 HeapObject::cast(*object)->map()->has_instance_call_handler()) { | 207 HeapObject::cast(*object)->map()->has_instance_call_handler()) { |
| 206 return Handle<JSFunction>( | 208 return Handle<JSFunction>( |
| 207 Top::global_context()->call_as_function_delegate()); | 209 Isolate::Current()->global_context()->call_as_function_delegate()); |
| 208 } | 210 } |
| 209 | 211 |
| 210 return Factory::undefined_value(); | 212 return Factory::undefined_value(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 | 215 |
| 214 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) { | 216 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) { |
| 215 ASSERT(!object->IsJSFunction()); | 217 ASSERT(!object->IsJSFunction()); |
| 216 | 218 |
| 217 // If you return a function from here, it will be called when an | 219 // If you return a function from here, it will be called when an |
| 218 // attempt is made to call the given object as a constructor. | 220 // attempt is made to call the given object as a constructor. |
| 219 | 221 |
| 220 // Objects created through the API can have an instance-call handler | 222 // Objects created through the API can have an instance-call handler |
| 221 // that should be used when calling the object as a function. | 223 // that should be used when calling the object as a function. |
| 222 if (object->IsHeapObject() && | 224 if (object->IsHeapObject() && |
| 223 HeapObject::cast(*object)->map()->has_instance_call_handler()) { | 225 HeapObject::cast(*object)->map()->has_instance_call_handler()) { |
| 224 return Handle<JSFunction>( | 226 return Handle<JSFunction>( |
| 225 Top::global_context()->call_as_constructor_delegate()); | 227 Isolate::Current()->global_context()->call_as_constructor_delegate()); |
| 226 } | 228 } |
| 227 | 229 |
| 228 return Factory::undefined_value(); | 230 return Factory::undefined_value(); |
| 229 } | 231 } |
| 230 | 232 |
| 231 | 233 |
| 232 bool StackGuard::IsStackOverflow() { | 234 bool StackGuard::IsStackOverflow() { |
| 233 ExecutionAccess access; | 235 ExecutionAccess access; |
| 234 return (thread_local_.jslimit_ != kInterruptLimit && | 236 return (thread_local_.jslimit_ != kInterruptLimit && |
| 235 thread_local_.climit_ != kInterruptLimit); | 237 thread_local_.climit_ != kInterruptLimit); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 ExecutionAccess access; | 349 ExecutionAccess access; |
| 348 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 350 memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
| 349 ThreadLocal blank; | 351 ThreadLocal blank; |
| 350 | 352 |
| 351 // Set the stack limits using the old thread_local_. | 353 // Set the stack limits using the old thread_local_. |
| 352 // TODO(isolates): This was the old semantics of constructing a ThreadLocal | 354 // TODO(isolates): This was the old semantics of constructing a ThreadLocal |
| 353 // (as the ctor called SetStackLimits, which looked at the | 355 // (as the ctor called SetStackLimits, which looked at the |
| 354 // current thread_local_ from StackGuard)-- but is this | 356 // current thread_local_ from StackGuard)-- but is this |
| 355 // really what was intended? | 357 // really what was intended? |
| 356 isolate_->heap()->SetStackLimits(); | 358 isolate_->heap()->SetStackLimits(); |
| 359 thread_local_ = blank; |
| 357 | 360 |
| 358 thread_local_ = blank; | |
| 359 return to + sizeof(ThreadLocal); | 361 return to + sizeof(ThreadLocal); |
| 360 } | 362 } |
| 361 | 363 |
| 362 | 364 |
| 363 char* StackGuard::RestoreStackGuard(char* from) { | 365 char* StackGuard::RestoreStackGuard(char* from) { |
| 364 ExecutionAccess access; | 366 ExecutionAccess access; |
| 365 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); | 367 memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); |
| 366 isolate_->heap()->SetStackLimits(); | 368 isolate_->heap()->SetStackLimits(); |
| 367 return from + sizeof(ThreadLocal); | 369 return from + sizeof(ThreadLocal); |
| 368 } | 370 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 void* stored_limit = Thread::GetThreadLocal(stack_limit_key); | 423 void* stored_limit = Thread::GetThreadLocal(stack_limit_key); |
| 422 // You should hold the ExecutionAccess lock when you call this. | 424 // You should hold the ExecutionAccess lock when you call this. |
| 423 if (stored_limit != NULL) { | 425 if (stored_limit != NULL) { |
| 424 StackGuard::SetStackLimit(reinterpret_cast<intptr_t>(stored_limit)); | 426 StackGuard::SetStackLimit(reinterpret_cast<intptr_t>(stored_limit)); |
| 425 } | 427 } |
| 426 } | 428 } |
| 427 | 429 |
| 428 | 430 |
| 429 // --- C a l l s t o n a t i v e s --- | 431 // --- C a l l s t o n a t i v e s --- |
| 430 | 432 |
| 431 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ | 433 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ |
| 432 do { \ | 434 do { \ |
| 433 Object** args[argc] = argv; \ | 435 Object** args[argc] = argv; \ |
| 434 ASSERT(has_pending_exception != NULL); \ | 436 ASSERT(has_pending_exception != NULL); \ |
| 435 return Call(Top::name##_fun(), Top::builtins(), argc, args, \ | 437 return Call(Isolate::Current()->name##_fun(), \ |
| 436 has_pending_exception); \ | 438 Isolate::Current()->builtins(), argc, args, \ |
| 439 has_pending_exception); \ |
| 437 } while (false) | 440 } while (false) |
| 438 | 441 |
| 439 | 442 |
| 440 Handle<Object> Execution::ToBoolean(Handle<Object> obj) { | 443 Handle<Object> Execution::ToBoolean(Handle<Object> obj) { |
| 441 // See the similar code in runtime.js:ToBoolean. | 444 // See the similar code in runtime.js:ToBoolean. |
| 442 if (obj->IsBoolean()) return obj; | 445 if (obj->IsBoolean()) return obj; |
| 443 bool result = true; | 446 bool result = true; |
| 444 if (obj->IsString()) { | 447 if (obj->IsString()) { |
| 445 result = Handle<String>::cast(obj)->length() != 0; | 448 result = Handle<String>::cast(obj)->length() != 0; |
| 446 } else if (obj->IsNull() || obj->IsUndefined()) { | 449 } else if (obj->IsNull() || obj->IsUndefined()) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 #undef RETURN_NATIVE_CALL | 501 #undef RETURN_NATIVE_CALL |
| 499 | 502 |
| 500 | 503 |
| 501 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { | 504 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { |
| 502 int int_index = static_cast<int>(index); | 505 int int_index = static_cast<int>(index); |
| 503 if (int_index < 0 || int_index >= string->length()) { | 506 if (int_index < 0 || int_index >= string->length()) { |
| 504 return Factory::undefined_value(); | 507 return Factory::undefined_value(); |
| 505 } | 508 } |
| 506 | 509 |
| 507 Handle<Object> char_at = | 510 Handle<Object> char_at = |
| 508 GetProperty(Top::builtins(), Factory::char_at_symbol()); | 511 GetProperty(Isolate::Current()->builtins(), Factory::char_at_symbol()); |
| 509 if (!char_at->IsJSFunction()) { | 512 if (!char_at->IsJSFunction()) { |
| 510 return Factory::undefined_value(); | 513 return Factory::undefined_value(); |
| 511 } | 514 } |
| 512 | 515 |
| 513 bool caught_exception; | 516 bool caught_exception; |
| 514 Handle<Object> index_object = Factory::NewNumberFromInt(int_index); | 517 Handle<Object> index_object = Factory::NewNumberFromInt(int_index); |
| 515 Object** index_arg[] = { index_object.location() }; | 518 Object** index_arg[] = { index_object.location() }; |
| 516 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at), | 519 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at), |
| 517 string, | 520 string, |
| 518 ARRAY_SIZE(index_arg), | 521 ARRAY_SIZE(index_arg), |
| 519 index_arg, | 522 index_arg, |
| 520 &caught_exception); | 523 &caught_exception); |
| 521 if (caught_exception) { | 524 if (caught_exception) { |
| 522 return Factory::undefined_value(); | 525 return Factory::undefined_value(); |
| 523 } | 526 } |
| 524 return result; | 527 return result; |
| 525 } | 528 } |
| 526 | 529 |
| 527 | 530 |
| 528 Handle<JSFunction> Execution::InstantiateFunction( | 531 Handle<JSFunction> Execution::InstantiateFunction( |
| 529 Handle<FunctionTemplateInfo> data, bool* exc) { | 532 Handle<FunctionTemplateInfo> data, bool* exc) { |
| 530 // Fast case: see if the function has already been instantiated | 533 // Fast case: see if the function has already been instantiated |
| 531 int serial_number = Smi::cast(data->serial_number())->value(); | 534 int serial_number = Smi::cast(data->serial_number())->value(); |
| 532 Object* elm = | 535 Object* elm = |
| 533 Top::global_context()->function_cache()->GetElement(serial_number); | 536 Isolate::Current()->global_context()->function_cache()-> |
| 537 GetElement(serial_number); |
| 534 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); | 538 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); |
| 535 // The function has not yet been instantiated in this context; do it. | 539 // The function has not yet been instantiated in this context; do it. |
| 536 Object** args[1] = { Handle<Object>::cast(data).location() }; | 540 Object** args[1] = { Handle<Object>::cast(data).location() }; |
| 537 Handle<Object> result = | 541 Handle<Object> result = |
| 538 Call(Top::instantiate_fun(), Top::builtins(), 1, args, exc); | 542 Call(Isolate::Current()->instantiate_fun(), |
| 543 Isolate::Current()->builtins(), 1, args, exc); |
| 539 if (*exc) return Handle<JSFunction>::null(); | 544 if (*exc) return Handle<JSFunction>::null(); |
| 540 return Handle<JSFunction>::cast(result); | 545 return Handle<JSFunction>::cast(result); |
| 541 } | 546 } |
| 542 | 547 |
| 543 | 548 |
| 544 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, | 549 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, |
| 545 bool* exc) { | 550 bool* exc) { |
| 546 if (data->property_list()->IsUndefined() && | 551 if (data->property_list()->IsUndefined() && |
| 547 !data->constructor()->IsUndefined()) { | 552 !data->constructor()->IsUndefined()) { |
| 548 // Initialization to make gcc happy. | 553 // Initialization to make gcc happy. |
| 549 Object* result = NULL; | 554 Object* result = NULL; |
| 550 { | 555 { |
| 551 HandleScope scope; | 556 HandleScope scope; |
| 552 Handle<FunctionTemplateInfo> cons_template = | 557 Handle<FunctionTemplateInfo> cons_template = |
| 553 Handle<FunctionTemplateInfo>( | 558 Handle<FunctionTemplateInfo>( |
| 554 FunctionTemplateInfo::cast(data->constructor())); | 559 FunctionTemplateInfo::cast(data->constructor())); |
| 555 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc); | 560 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc); |
| 556 if (*exc) return Handle<JSObject>::null(); | 561 if (*exc) return Handle<JSObject>::null(); |
| 557 Handle<Object> value = New(cons, 0, NULL, exc); | 562 Handle<Object> value = New(cons, 0, NULL, exc); |
| 558 if (*exc) return Handle<JSObject>::null(); | 563 if (*exc) return Handle<JSObject>::null(); |
| 559 result = *value; | 564 result = *value; |
| 560 } | 565 } |
| 561 ASSERT(!*exc); | 566 ASSERT(!*exc); |
| 562 return Handle<JSObject>(JSObject::cast(result)); | 567 return Handle<JSObject>(JSObject::cast(result)); |
| 563 } else { | 568 } else { |
| 564 Object** args[1] = { Handle<Object>::cast(data).location() }; | 569 Object** args[1] = { Handle<Object>::cast(data).location() }; |
| 565 Handle<Object> result = | 570 Handle<Object> result = |
| 566 Call(Top::instantiate_fun(), Top::builtins(), 1, args, exc); | 571 Call(Isolate::Current()->instantiate_fun(), |
| 572 Isolate::Current()->builtins(), 1, args, exc); |
| 567 if (*exc) return Handle<JSObject>::null(); | 573 if (*exc) return Handle<JSObject>::null(); |
| 568 return Handle<JSObject>::cast(result); | 574 return Handle<JSObject>::cast(result); |
| 569 } | 575 } |
| 570 } | 576 } |
| 571 | 577 |
| 572 | 578 |
| 573 void Execution::ConfigureInstance(Handle<Object> instance, | 579 void Execution::ConfigureInstance(Handle<Object> instance, |
| 574 Handle<Object> instance_template, | 580 Handle<Object> instance_template, |
| 575 bool* exc) { | 581 bool* exc) { |
| 576 Object** args[2] = { instance.location(), instance_template.location() }; | 582 Object** args[2] = { instance.location(), instance_template.location() }; |
| 577 Execution::Call(Top::configure_instance_fun(), Top::builtins(), 2, args, exc); | 583 Execution::Call(Isolate::Current()->configure_instance_fun(), |
| 584 Isolate::Current()->builtins(), 2, args, exc); |
| 578 } | 585 } |
| 579 | 586 |
| 580 | 587 |
| 581 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, | 588 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, |
| 582 Handle<JSFunction> fun, | 589 Handle<JSFunction> fun, |
| 583 Handle<Object> pos, | 590 Handle<Object> pos, |
| 584 Handle<Object> is_global) { | 591 Handle<Object> is_global) { |
| 585 const int argc = 4; | 592 const int argc = 4; |
| 586 Object** args[argc] = { recv.location(), | 593 Object** args[argc] = { recv.location(), |
| 587 Handle<Object>::cast(fun).location(), | 594 Handle<Object>::cast(fun).location(), |
| 588 pos.location(), | 595 pos.location(), |
| 589 is_global.location() }; | 596 is_global.location() }; |
| 590 bool caught_exception = false; | 597 bool caught_exception = false; |
| 591 Handle<Object> result = TryCall(Top::get_stack_trace_line_fun(), | 598 Handle<Object> result = |
| 592 Top::builtins(), argc, args, | 599 TryCall(Isolate::Current()->get_stack_trace_line_fun(), |
| 593 &caught_exception); | 600 Isolate::Current()->builtins(), argc, args, &caught_exception); |
| 594 if (caught_exception || !result->IsString()) return Factory::empty_symbol(); | 601 if (caught_exception || !result->IsString()) return Factory::empty_symbol(); |
| 595 return Handle<String>::cast(result); | 602 return Handle<String>::cast(result); |
| 596 } | 603 } |
| 597 | 604 |
| 598 | 605 |
| 599 static Object* RuntimePreempt() { | 606 static Object* RuntimePreempt() { |
| 600 Isolate* isolate = Isolate::Current(); | 607 Isolate* isolate = Isolate::Current(); |
| 601 | 608 |
| 602 // Clear the preempt request flag. | 609 // Clear the preempt request flag. |
| 603 isolate->stack_guard()->Continue(PREEMPT); | 610 isolate->stack_guard()->Continue(PREEMPT); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 Isolate* isolate = Isolate::Current(); | 701 Isolate* isolate = Isolate::Current(); |
| 695 #ifdef ENABLE_DEBUGGER_SUPPORT | 702 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 696 if (isolate->stack_guard()->IsDebugBreak() || | 703 if (isolate->stack_guard()->IsDebugBreak() || |
| 697 isolate->stack_guard()->IsDebugCommand()) { | 704 isolate->stack_guard()->IsDebugCommand()) { |
| 698 DebugBreakHelper(); | 705 DebugBreakHelper(); |
| 699 } | 706 } |
| 700 #endif | 707 #endif |
| 701 if (isolate->stack_guard()->IsPreempted()) RuntimePreempt(); | 708 if (isolate->stack_guard()->IsPreempted()) RuntimePreempt(); |
| 702 if (isolate->stack_guard()->IsTerminateExecution()) { | 709 if (isolate->stack_guard()->IsTerminateExecution()) { |
| 703 isolate->stack_guard()->Continue(TERMINATE); | 710 isolate->stack_guard()->Continue(TERMINATE); |
| 704 return Top::TerminateExecution(); | 711 return isolate->TerminateExecution(); |
| 705 } | 712 } |
| 706 if (isolate->stack_guard()->IsInterrupted()) { | 713 if (isolate->stack_guard()->IsInterrupted()) { |
| 707 // interrupt | 714 // interrupt |
| 708 isolate->stack_guard()->Continue(INTERRUPT); | 715 isolate->stack_guard()->Continue(INTERRUPT); |
| 709 return Top::StackOverflow(); | 716 return isolate->StackOverflow(); |
| 710 } | 717 } |
| 711 return isolate->heap()->undefined_value(); | 718 return isolate->heap()->undefined_value(); |
| 712 } | 719 } |
| 713 | 720 |
| 714 // --- G C E x t e n s i o n --- | 721 // --- G C E x t e n s i o n --- |
| 715 | 722 |
| 716 const char* GCExtension::kSource = "native function gc();"; | 723 const char* GCExtension::kSource = "native function gc();"; |
| 717 | 724 |
| 718 | 725 |
| 719 v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction( | 726 v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction( |
| 720 v8::Handle<v8::String> str) { | 727 v8::Handle<v8::String> str) { |
| 721 return v8::FunctionTemplate::New(GCExtension::GC); | 728 return v8::FunctionTemplate::New(GCExtension::GC); |
| 722 } | 729 } |
| 723 | 730 |
| 724 | 731 |
| 725 v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) { | 732 v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) { |
| 726 // All allocation spaces other than NEW_SPACE have the same effect. | 733 // All allocation spaces other than NEW_SPACE have the same effect. |
| 727 HEAP->CollectAllGarbage(false); | 734 HEAP->CollectAllGarbage(false); |
| 728 return v8::Undefined(); | 735 return v8::Undefined(); |
| 729 } | 736 } |
| 730 | 737 |
| 731 | 738 |
| 732 static GCExtension kGCExtension; | 739 static GCExtension kGCExtension; |
| 733 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 740 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
| 734 | 741 |
| 735 } } // namespace v8::internal | 742 } } // namespace v8::internal |
| OLD | NEW |