OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 isolate->set_context(last_context); | 761 isolate->set_context(last_context); |
762 isolate->set_context_exit_happened(true); | 762 isolate->set_context_exit_happened(true); |
763 } | 763 } |
764 | 764 |
765 | 765 |
766 void Context::SetData(v8::Handle<String> data) { | 766 void Context::SetData(v8::Handle<String> data) { |
767 i::Handle<i::Context> env = Utils::OpenHandle(this); | 767 i::Handle<i::Context> env = Utils::OpenHandle(this); |
768 i::Isolate* isolate = env->GetIsolate(); | 768 i::Isolate* isolate = env->GetIsolate(); |
769 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; | 769 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; |
770 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); | 770 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); |
771 ASSERT(env->IsNativeContext()); | 771 ASSERT(env->IsGlobalContext()); |
772 if (env->IsNativeContext()) { | 772 if (env->IsGlobalContext()) { |
773 env->set_data(*raw_data); | 773 env->set_data(*raw_data); |
774 } | 774 } |
775 } | 775 } |
776 | 776 |
777 | 777 |
778 v8::Local<v8::Value> Context::GetData() { | 778 v8::Local<v8::Value> Context::GetData() { |
779 i::Handle<i::Context> env = Utils::OpenHandle(this); | 779 i::Handle<i::Context> env = Utils::OpenHandle(this); |
780 i::Isolate* isolate = env->GetIsolate(); | 780 i::Isolate* isolate = env->GetIsolate(); |
781 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { | 781 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { |
782 return v8::Local<Value>(); | 782 return v8::Local<Value>(); |
783 } | 783 } |
784 i::Object* raw_result = NULL; | 784 i::Object* raw_result = NULL; |
785 ASSERT(env->IsNativeContext()); | 785 ASSERT(env->IsGlobalContext()); |
786 if (env->IsNativeContext()) { | 786 if (env->IsGlobalContext()) { |
787 raw_result = env->data(); | 787 raw_result = env->data(); |
788 } else { | 788 } else { |
789 return Local<Value>(); | 789 return Local<Value>(); |
790 } | 790 } |
791 i::Handle<i::Object> result(raw_result, isolate); | 791 i::Handle<i::Object> result(raw_result, isolate); |
792 return Utils::ToLocal(result); | 792 return Utils::ToLocal(result); |
793 } | 793 } |
794 | 794 |
795 | 795 |
796 i::Object** v8::HandleScope::RawClose(i::Object** value) { | 796 i::Object** v8::HandleScope::RawClose(i::Object** value) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 | 1060 |
1061 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1061 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1062 v8::Handle<String> name, | 1062 v8::Handle<String> name, |
1063 AccessorGetter getter, | 1063 AccessorGetter getter, |
1064 AccessorSetter setter, | 1064 AccessorSetter setter, |
1065 v8::Handle<Value> data, | 1065 v8::Handle<Value> data, |
1066 v8::AccessControl settings, | 1066 v8::AccessControl settings, |
1067 v8::PropertyAttribute attributes, | 1067 v8::PropertyAttribute attributes, |
1068 v8::Handle<AccessorSignature> signature) { | 1068 v8::Handle<AccessorSignature> signature) { |
1069 i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); | 1069 i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); |
| 1070 ASSERT(getter != NULL); |
1070 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1071 SET_FIELD_WRAPPED(obj, set_getter, getter); |
1071 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1072 SET_FIELD_WRAPPED(obj, set_setter, setter); |
1072 if (data.IsEmpty()) data = v8::Undefined(); | 1073 if (data.IsEmpty()) data = v8::Undefined(); |
1073 obj->set_data(*Utils::OpenHandle(*data)); | 1074 obj->set_data(*Utils::OpenHandle(*data)); |
1074 obj->set_name(*Utils::OpenHandle(*name)); | 1075 obj->set_name(*Utils::OpenHandle(*name)); |
1075 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1076 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
1076 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1077 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
1077 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 1078 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
1078 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1079 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
1079 if (!signature.IsEmpty()) { | 1080 if (!signature.IsEmpty()) { |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 ENTER_V8(isolate); | 1568 ENTER_V8(isolate); |
1568 Local<Script> generic = New(source, origin, pre_data, script_data); | 1569 Local<Script> generic = New(source, origin, pre_data, script_data); |
1569 if (generic.IsEmpty()) | 1570 if (generic.IsEmpty()) |
1570 return generic; | 1571 return generic; |
1571 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); | 1572 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); |
1572 i::Handle<i::SharedFunctionInfo> function = | 1573 i::Handle<i::SharedFunctionInfo> function = |
1573 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); | 1574 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); |
1574 i::Handle<i::JSFunction> result = | 1575 i::Handle<i::JSFunction> result = |
1575 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1576 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1576 function, | 1577 function, |
1577 isolate->native_context()); | 1578 isolate->global_context()); |
1578 return Local<Script>(ToApi<Script>(result)); | 1579 return Local<Script>(ToApi<Script>(result)); |
1579 } | 1580 } |
1580 | 1581 |
1581 | 1582 |
1582 Local<Script> Script::Compile(v8::Handle<String> source, | 1583 Local<Script> Script::Compile(v8::Handle<String> source, |
1583 v8::Handle<Value> file_name, | 1584 v8::Handle<Value> file_name, |
1584 v8::Handle<String> script_data) { | 1585 v8::Handle<String> script_data) { |
1585 ScriptOrigin origin(file_name); | 1586 ScriptOrigin origin(file_name); |
1586 return Compile(source, &origin, 0, script_data); | 1587 return Compile(source, &origin, 0, script_data); |
1587 } | 1588 } |
1588 | 1589 |
1589 | 1590 |
1590 Local<Value> Script::Run() { | 1591 Local<Value> Script::Run() { |
1591 i::Isolate* isolate = i::Isolate::Current(); | 1592 i::Isolate* isolate = i::Isolate::Current(); |
1592 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); | 1593 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); |
1593 LOG_API(isolate, "Script::Run"); | 1594 LOG_API(isolate, "Script::Run"); |
1594 ENTER_V8(isolate); | 1595 ENTER_V8(isolate); |
1595 i::Object* raw_result = NULL; | 1596 i::Object* raw_result = NULL; |
1596 { | 1597 { |
1597 i::HandleScope scope(isolate); | 1598 i::HandleScope scope(isolate); |
1598 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1599 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1599 i::Handle<i::JSFunction> fun; | 1600 i::Handle<i::JSFunction> fun; |
1600 if (obj->IsSharedFunctionInfo()) { | 1601 if (obj->IsSharedFunctionInfo()) { |
1601 i::Handle<i::SharedFunctionInfo> | 1602 i::Handle<i::SharedFunctionInfo> |
1602 function_info(i::SharedFunctionInfo::cast(*obj), isolate); | 1603 function_info(i::SharedFunctionInfo::cast(*obj), isolate); |
1603 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1604 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1604 function_info, isolate->native_context()); | 1605 function_info, isolate->global_context()); |
1605 } else { | 1606 } else { |
1606 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); | 1607 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); |
1607 } | 1608 } |
1608 EXCEPTION_PREAMBLE(isolate); | 1609 EXCEPTION_PREAMBLE(isolate); |
1609 i::Handle<i::Object> receiver( | 1610 i::Handle<i::Object> receiver( |
1610 isolate->context()->global_proxy(), isolate); | 1611 isolate->context()->global_proxy(), isolate); |
1611 i::Handle<i::Object> result = | 1612 i::Handle<i::Object> result = |
1612 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1613 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
1613 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); | 1614 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); |
1614 raw_result = *result; | 1615 raw_result = *result; |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3262 i::Object* constructor = object->map()->constructor(); | 3263 i::Object* constructor = object->map()->constructor(); |
3263 i::JSFunction* function; | 3264 i::JSFunction* function; |
3264 if (!constructor->IsJSFunction()) { | 3265 if (!constructor->IsJSFunction()) { |
3265 // Functions have null as a constructor, | 3266 // Functions have null as a constructor, |
3266 // but any JSFunction knows its context immediately. | 3267 // but any JSFunction knows its context immediately. |
3267 ASSERT(object->IsJSFunction()); | 3268 ASSERT(object->IsJSFunction()); |
3268 function = i::JSFunction::cast(object); | 3269 function = i::JSFunction::cast(object); |
3269 } else { | 3270 } else { |
3270 function = i::JSFunction::cast(constructor); | 3271 function = i::JSFunction::cast(constructor); |
3271 } | 3272 } |
3272 return function->context()->native_context(); | 3273 return function->context()->global_context(); |
3273 } | 3274 } |
3274 | 3275 |
3275 | 3276 |
3276 Local<v8::Context> v8::Object::CreationContext() { | 3277 Local<v8::Context> v8::Object::CreationContext() { |
3277 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3278 ON_BAILOUT(isolate, | 3279 ON_BAILOUT(isolate, |
3279 "v8::Object::CreationContext()", return Local<v8::Context>()); | 3280 "v8::Object::CreationContext()", return Local<v8::Context>()); |
3280 ENTER_V8(isolate); | 3281 ENTER_V8(isolate); |
3281 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3282 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3282 i::Context* context = GetCreationContext(*self); | 3283 i::Context* context = GetCreationContext(*self); |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4431 | 4432 |
4432 | 4433 |
4433 void v8::Context::UseDefaultSecurityToken() { | 4434 void v8::Context::UseDefaultSecurityToken() { |
4434 i::Isolate* isolate = i::Isolate::Current(); | 4435 i::Isolate* isolate = i::Isolate::Current(); |
4435 if (IsDeadCheck(isolate, | 4436 if (IsDeadCheck(isolate, |
4436 "v8::Context::UseDefaultSecurityToken()")) { | 4437 "v8::Context::UseDefaultSecurityToken()")) { |
4437 return; | 4438 return; |
4438 } | 4439 } |
4439 ENTER_V8(isolate); | 4440 ENTER_V8(isolate); |
4440 i::Handle<i::Context> env = Utils::OpenHandle(this); | 4441 i::Handle<i::Context> env = Utils::OpenHandle(this); |
4441 env->set_security_token(env->global_object()); | 4442 env->set_security_token(env->global()); |
4442 } | 4443 } |
4443 | 4444 |
4444 | 4445 |
4445 Handle<Value> v8::Context::GetSecurityToken() { | 4446 Handle<Value> v8::Context::GetSecurityToken() { |
4446 i::Isolate* isolate = i::Isolate::Current(); | 4447 i::Isolate* isolate = i::Isolate::Current(); |
4447 if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) { | 4448 if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) { |
4448 return Handle<Value>(); | 4449 return Handle<Value>(); |
4449 } | 4450 } |
4450 i::Handle<i::Context> env = Utils::OpenHandle(this); | 4451 i::Handle<i::Context> env = Utils::OpenHandle(this); |
4451 i::Object* security_token = env->security_token(); | 4452 i::Object* security_token = env->security_token(); |
(...skipping 24 matching lines...) Expand all Loading... |
4476 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); | 4477 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); |
4477 return Utils::ToLocal(context); | 4478 return Utils::ToLocal(context); |
4478 } | 4479 } |
4479 | 4480 |
4480 | 4481 |
4481 v8::Local<v8::Context> Context::GetCurrent() { | 4482 v8::Local<v8::Context> Context::GetCurrent() { |
4482 i::Isolate* isolate = i::Isolate::Current(); | 4483 i::Isolate* isolate = i::Isolate::Current(); |
4483 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) { | 4484 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) { |
4484 return Local<Context>(); | 4485 return Local<Context>(); |
4485 } | 4486 } |
4486 i::Handle<i::Object> current = isolate->native_context(); | 4487 i::Handle<i::Object> current = isolate->global_context(); |
4487 if (current.is_null()) return Local<Context>(); | 4488 if (current.is_null()) return Local<Context>(); |
4488 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); | 4489 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); |
4489 return Utils::ToLocal(context); | 4490 return Utils::ToLocal(context); |
4490 } | 4491 } |
4491 | 4492 |
4492 | 4493 |
4493 v8::Local<v8::Context> Context::GetCalling() { | 4494 v8::Local<v8::Context> Context::GetCalling() { |
4494 i::Isolate* isolate = i::Isolate::Current(); | 4495 i::Isolate* isolate = i::Isolate::Current(); |
4495 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { | 4496 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { |
4496 return Local<Context>(); | 4497 return Local<Context>(); |
4497 } | 4498 } |
4498 i::Handle<i::Object> calling = | 4499 i::Handle<i::Object> calling = |
4499 isolate->GetCallingNativeContext(); | 4500 isolate->GetCallingGlobalContext(); |
4500 if (calling.is_null()) return Local<Context>(); | 4501 if (calling.is_null()) return Local<Context>(); |
4501 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); | 4502 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); |
4502 return Utils::ToLocal(context); | 4503 return Utils::ToLocal(context); |
4503 } | 4504 } |
4504 | 4505 |
4505 | 4506 |
4506 v8::Local<v8::Object> Context::Global() { | 4507 v8::Local<v8::Object> Context::Global() { |
4507 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { | 4508 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { |
4508 return Local<v8::Object>(); | 4509 return Local<v8::Object>(); |
4509 } | 4510 } |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5790 | 5791 |
5791 | 5792 |
5792 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { | 5793 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { |
5793 i::Isolate* isolate = i::Isolate::Current(); | 5794 i::Isolate* isolate = i::Isolate::Current(); |
5794 if (!isolate->IsInitialized()) return Local<Value>(); | 5795 if (!isolate->IsInitialized()) return Local<Value>(); |
5795 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); | 5796 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); |
5796 ENTER_V8(isolate); | 5797 ENTER_V8(isolate); |
5797 v8::HandleScope scope; | 5798 v8::HandleScope scope; |
5798 i::Debug* isolate_debug = isolate->debug(); | 5799 i::Debug* isolate_debug = isolate->debug(); |
5799 isolate_debug->Load(); | 5800 isolate_debug->Load(); |
5800 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 5801 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global()); |
5801 i::Handle<i::String> name = | 5802 i::Handle<i::String> name = |
5802 isolate->factory()->LookupAsciiSymbol("MakeMirror"); | 5803 isolate->factory()->LookupAsciiSymbol("MakeMirror"); |
5803 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name); | 5804 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name); |
5804 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); | 5805 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); |
5805 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); | 5806 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); |
5806 const int kArgc = 1; | 5807 const int kArgc = 1; |
5807 v8::Handle<v8::Value> argv[kArgc] = { obj }; | 5808 v8::Handle<v8::Value> argv[kArgc] = { obj }; |
5808 EXCEPTION_PREAMBLE(isolate); | 5809 EXCEPTION_PREAMBLE(isolate); |
5809 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug), | 5810 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug), |
5810 kArgc, | 5811 kArgc, |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6525 | 6526 |
6526 v->VisitPointers(blocks_.first(), first_block_limit_); | 6527 v->VisitPointers(blocks_.first(), first_block_limit_); |
6527 | 6528 |
6528 for (int i = 1; i < blocks_.length(); i++) { | 6529 for (int i = 1; i < blocks_.length(); i++) { |
6529 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6530 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
6530 } | 6531 } |
6531 } | 6532 } |
6532 | 6533 |
6533 | 6534 |
6534 } } // namespace v8::internal | 6535 } } // namespace v8::internal |
OLD | NEW |