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->IsGlobalContext()); | 771 ASSERT(env->IsNativeContext()); |
772 if (env->IsGlobalContext()) { | 772 if (env->IsNativeContext()) { |
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->IsGlobalContext()); | 785 ASSERT(env->IsNativeContext()); |
786 if (env->IsGlobalContext()) { | 786 if (env->IsNativeContext()) { |
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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 ENTER_V8(isolate); | 1568 ENTER_V8(isolate); |
1569 Local<Script> generic = New(source, origin, pre_data, script_data); | 1569 Local<Script> generic = New(source, origin, pre_data, script_data); |
1570 if (generic.IsEmpty()) | 1570 if (generic.IsEmpty()) |
1571 return generic; | 1571 return generic; |
1572 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); | 1572 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); |
1573 i::Handle<i::SharedFunctionInfo> function = | 1573 i::Handle<i::SharedFunctionInfo> function = |
1574 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); | 1574 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); |
1575 i::Handle<i::JSFunction> result = | 1575 i::Handle<i::JSFunction> result = |
1576 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1576 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1577 function, | 1577 function, |
1578 isolate->global_context()); | 1578 isolate->native_context()); |
1579 return Local<Script>(ToApi<Script>(result)); | 1579 return Local<Script>(ToApi<Script>(result)); |
1580 } | 1580 } |
1581 | 1581 |
1582 | 1582 |
1583 Local<Script> Script::Compile(v8::Handle<String> source, | 1583 Local<Script> Script::Compile(v8::Handle<String> source, |
1584 v8::Handle<Value> file_name, | 1584 v8::Handle<Value> file_name, |
1585 v8::Handle<String> script_data) { | 1585 v8::Handle<String> script_data) { |
1586 ScriptOrigin origin(file_name); | 1586 ScriptOrigin origin(file_name); |
1587 return Compile(source, &origin, 0, script_data); | 1587 return Compile(source, &origin, 0, script_data); |
1588 } | 1588 } |
1589 | 1589 |
1590 | 1590 |
1591 Local<Value> Script::Run() { | 1591 Local<Value> Script::Run() { |
1592 i::Isolate* isolate = i::Isolate::Current(); | 1592 i::Isolate* isolate = i::Isolate::Current(); |
1593 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); | 1593 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); |
1594 LOG_API(isolate, "Script::Run"); | 1594 LOG_API(isolate, "Script::Run"); |
1595 ENTER_V8(isolate); | 1595 ENTER_V8(isolate); |
1596 i::Object* raw_result = NULL; | 1596 i::Object* raw_result = NULL; |
1597 { | 1597 { |
1598 i::HandleScope scope(isolate); | 1598 i::HandleScope scope(isolate); |
1599 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1599 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1600 i::Handle<i::JSFunction> fun; | 1600 i::Handle<i::JSFunction> fun; |
1601 if (obj->IsSharedFunctionInfo()) { | 1601 if (obj->IsSharedFunctionInfo()) { |
1602 i::Handle<i::SharedFunctionInfo> | 1602 i::Handle<i::SharedFunctionInfo> |
1603 function_info(i::SharedFunctionInfo::cast(*obj), isolate); | 1603 function_info(i::SharedFunctionInfo::cast(*obj), isolate); |
1604 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1604 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1605 function_info, isolate->global_context()); | 1605 function_info, isolate->native_context()); |
1606 } else { | 1606 } else { |
1607 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); | 1607 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); |
1608 } | 1608 } |
1609 EXCEPTION_PREAMBLE(isolate); | 1609 EXCEPTION_PREAMBLE(isolate); |
1610 i::Handle<i::Object> receiver( | 1610 i::Handle<i::Object> receiver( |
1611 isolate->context()->global_proxy(), isolate); | 1611 isolate->context()->global_proxy(), isolate); |
1612 i::Handle<i::Object> result = | 1612 i::Handle<i::Object> result = |
1613 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1613 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
1614 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); | 1614 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); |
1615 raw_result = *result; | 1615 raw_result = *result; |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3263 i::Object* constructor = object->map()->constructor(); | 3263 i::Object* constructor = object->map()->constructor(); |
3264 i::JSFunction* function; | 3264 i::JSFunction* function; |
3265 if (!constructor->IsJSFunction()) { | 3265 if (!constructor->IsJSFunction()) { |
3266 // Functions have null as a constructor, | 3266 // Functions have null as a constructor, |
3267 // but any JSFunction knows its context immediately. | 3267 // but any JSFunction knows its context immediately. |
3268 ASSERT(object->IsJSFunction()); | 3268 ASSERT(object->IsJSFunction()); |
3269 function = i::JSFunction::cast(object); | 3269 function = i::JSFunction::cast(object); |
3270 } else { | 3270 } else { |
3271 function = i::JSFunction::cast(constructor); | 3271 function = i::JSFunction::cast(constructor); |
3272 } | 3272 } |
3273 return function->context()->global_context(); | 3273 return function->context()->native_context(); |
3274 } | 3274 } |
3275 | 3275 |
3276 | 3276 |
3277 Local<v8::Context> v8::Object::CreationContext() { | 3277 Local<v8::Context> v8::Object::CreationContext() { |
3278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3279 ON_BAILOUT(isolate, | 3279 ON_BAILOUT(isolate, |
3280 "v8::Object::CreationContext()", return Local<v8::Context>()); | 3280 "v8::Object::CreationContext()", return Local<v8::Context>()); |
3281 ENTER_V8(isolate); | 3281 ENTER_V8(isolate); |
3282 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3282 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3283 i::Context* context = GetCreationContext(*self); | 3283 i::Context* context = GetCreationContext(*self); |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4477 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); | 4477 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); |
4478 return Utils::ToLocal(context); | 4478 return Utils::ToLocal(context); |
4479 } | 4479 } |
4480 | 4480 |
4481 | 4481 |
4482 v8::Local<v8::Context> Context::GetCurrent() { | 4482 v8::Local<v8::Context> Context::GetCurrent() { |
4483 i::Isolate* isolate = i::Isolate::Current(); | 4483 i::Isolate* isolate = i::Isolate::Current(); |
4484 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) { | 4484 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) { |
4485 return Local<Context>(); | 4485 return Local<Context>(); |
4486 } | 4486 } |
4487 i::Handle<i::Object> current = isolate->global_context(); | 4487 i::Handle<i::Object> current = isolate->native_context(); |
4488 if (current.is_null()) return Local<Context>(); | 4488 if (current.is_null()) return Local<Context>(); |
4489 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); | 4489 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); |
4490 return Utils::ToLocal(context); | 4490 return Utils::ToLocal(context); |
4491 } | 4491 } |
4492 | 4492 |
4493 | 4493 |
4494 v8::Local<v8::Context> Context::GetCalling() { | 4494 v8::Local<v8::Context> Context::GetCalling() { |
4495 i::Isolate* isolate = i::Isolate::Current(); | 4495 i::Isolate* isolate = i::Isolate::Current(); |
4496 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { | 4496 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { |
4497 return Local<Context>(); | 4497 return Local<Context>(); |
4498 } | 4498 } |
4499 i::Handle<i::Object> calling = | 4499 i::Handle<i::Object> calling = |
4500 isolate->GetCallingGlobalContext(); | 4500 isolate->GetCallingNativeContext(); |
4501 if (calling.is_null()) return Local<Context>(); | 4501 if (calling.is_null()) return Local<Context>(); |
4502 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); | 4502 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); |
4503 return Utils::ToLocal(context); | 4503 return Utils::ToLocal(context); |
4504 } | 4504 } |
4505 | 4505 |
4506 | 4506 |
4507 v8::Local<v8::Object> Context::Global() { | 4507 v8::Local<v8::Object> Context::Global() { |
4508 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { | 4508 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { |
4509 return Local<v8::Object>(); | 4509 return Local<v8::Object>(); |
4510 } | 4510 } |
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6526 | 6526 |
6527 v->VisitPointers(blocks_.first(), first_block_limit_); | 6527 v->VisitPointers(blocks_.first(), first_block_limit_); |
6528 | 6528 |
6529 for (int i = 1; i < blocks_.length(); i++) { | 6529 for (int i = 1; i < blocks_.length(); i++) { |
6530 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6530 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
6531 } | 6531 } |
6532 } | 6532 } |
6533 | 6533 |
6534 | 6534 |
6535 } } // namespace v8::internal | 6535 } } // namespace v8::internal |
OLD | NEW |