| 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 }; | 782 }; |
| 783 | 783 |
| 784 | 784 |
| 785 static MayAccessDecision MayAccessPreCheck(Isolate* isolate, | 785 static MayAccessDecision MayAccessPreCheck(Isolate* isolate, |
| 786 JSObject* receiver, | 786 JSObject* receiver, |
| 787 v8::AccessType type) { | 787 v8::AccessType type) { |
| 788 // During bootstrapping, callback functions are not enabled yet. | 788 // During bootstrapping, callback functions are not enabled yet. |
| 789 if (isolate->bootstrapper()->IsActive()) return YES; | 789 if (isolate->bootstrapper()->IsActive()) return YES; |
| 790 | 790 |
| 791 if (receiver->IsJSGlobalProxy()) { | 791 if (receiver->IsJSGlobalProxy()) { |
| 792 Object* receiver_context = JSGlobalProxy::cast(receiver)->native_context(); | 792 Object* receiver_context = JSGlobalProxy::cast(receiver)->context(); |
| 793 if (!receiver_context->IsContext()) return NO; | 793 if (!receiver_context->IsContext()) return NO; |
| 794 | 794 |
| 795 // Get the native context of current top context. | 795 // Get the global context of current top context. |
| 796 // avoid using Isolate::native_context() because it uses Handle. | 796 // avoid using Isolate::global_context() because it uses Handle. |
| 797 Context* native_context = | 797 Context* global_context = isolate->context()->global()->global_context(); |
| 798 isolate->context()->global_object()->native_context(); | 798 if (receiver_context == global_context) return YES; |
| 799 if (receiver_context == native_context) return YES; | |
| 800 | 799 |
| 801 if (Context::cast(receiver_context)->security_token() == | 800 if (Context::cast(receiver_context)->security_token() == |
| 802 native_context->security_token()) | 801 global_context->security_token()) |
| 803 return YES; | 802 return YES; |
| 804 } | 803 } |
| 805 | 804 |
| 806 return UNKNOWN; | 805 return UNKNOWN; |
| 807 } | 806 } |
| 808 | 807 |
| 809 | 808 |
| 810 bool Isolate::MayNamedAccess(JSObject* receiver, Object* key, | 809 bool Isolate::MayNamedAccess(JSObject* receiver, Object* key, |
| 811 v8::AccessType type) { | 810 v8::AccessType type) { |
| 812 ASSERT(receiver->IsAccessCheckNeeded()); | 811 ASSERT(receiver->IsAccessCheckNeeded()); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 | 1206 |
| 1208 return true; | 1207 return true; |
| 1209 } | 1208 } |
| 1210 | 1209 |
| 1211 | 1210 |
| 1212 void Isolate::ReportPendingMessages() { | 1211 void Isolate::ReportPendingMessages() { |
| 1213 ASSERT(has_pending_exception()); | 1212 ASSERT(has_pending_exception()); |
| 1214 PropagatePendingExceptionToExternalTryCatch(); | 1213 PropagatePendingExceptionToExternalTryCatch(); |
| 1215 | 1214 |
| 1216 // If the pending exception is OutOfMemoryException set out_of_memory in | 1215 // If the pending exception is OutOfMemoryException set out_of_memory in |
| 1217 // the native context. Note: We have to mark the native context here | 1216 // the global context. Note: We have to mark the global context here |
| 1218 // since the GenerateThrowOutOfMemory stub cannot make a RuntimeCall to | 1217 // since the GenerateThrowOutOfMemory stub cannot make a RuntimeCall to |
| 1219 // set it. | 1218 // set it. |
| 1220 HandleScope scope; | 1219 HandleScope scope; |
| 1221 if (thread_local_top_.pending_exception_ == Failure::OutOfMemoryException()) { | 1220 if (thread_local_top_.pending_exception_ == Failure::OutOfMemoryException()) { |
| 1222 context()->mark_out_of_memory(); | 1221 context()->mark_out_of_memory(); |
| 1223 } else if (thread_local_top_.pending_exception_ == | 1222 } else if (thread_local_top_.pending_exception_ == |
| 1224 heap()->termination_exception()) { | 1223 heap()->termination_exception()) { |
| 1225 // Do nothing: if needed, the exception has been already propagated to | 1224 // Do nothing: if needed, the exception has been already propagated to |
| 1226 // v8::TryCatch. | 1225 // v8::TryCatch. |
| 1227 } else { | 1226 } else { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 if (has_scheduled_exception()) { | 1316 if (has_scheduled_exception()) { |
| 1318 MaybeObject* e = scheduled_exception(); | 1317 MaybeObject* e = scheduled_exception(); |
| 1319 if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) { | 1318 if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) { |
| 1320 return true; | 1319 return true; |
| 1321 } | 1320 } |
| 1322 } | 1321 } |
| 1323 return false; | 1322 return false; |
| 1324 } | 1323 } |
| 1325 | 1324 |
| 1326 | 1325 |
| 1327 Handle<Context> Isolate::native_context() { | 1326 Handle<Context> Isolate::global_context() { |
| 1328 GlobalObject* global = thread_local_top()->context_->global_object(); | 1327 GlobalObject* global = thread_local_top()->context_->global(); |
| 1329 return Handle<Context>(global->native_context()); | 1328 return Handle<Context>(global->global_context()); |
| 1330 } | 1329 } |
| 1331 | 1330 |
| 1332 | 1331 |
| 1333 Handle<Context> Isolate::GetCallingNativeContext() { | 1332 Handle<Context> Isolate::GetCallingGlobalContext() { |
| 1334 JavaScriptFrameIterator it; | 1333 JavaScriptFrameIterator it; |
| 1335 #ifdef ENABLE_DEBUGGER_SUPPORT | 1334 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1336 if (debug_->InDebugger()) { | 1335 if (debug_->InDebugger()) { |
| 1337 while (!it.done()) { | 1336 while (!it.done()) { |
| 1338 JavaScriptFrame* frame = it.frame(); | 1337 JavaScriptFrame* frame = it.frame(); |
| 1339 Context* context = Context::cast(frame->context()); | 1338 Context* context = Context::cast(frame->context()); |
| 1340 if (context->native_context() == *debug_->debug_context()) { | 1339 if (context->global_context() == *debug_->debug_context()) { |
| 1341 it.Advance(); | 1340 it.Advance(); |
| 1342 } else { | 1341 } else { |
| 1343 break; | 1342 break; |
| 1344 } | 1343 } |
| 1345 } | 1344 } |
| 1346 } | 1345 } |
| 1347 #endif // ENABLE_DEBUGGER_SUPPORT | 1346 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1348 if (it.done()) return Handle<Context>::null(); | 1347 if (it.done()) return Handle<Context>::null(); |
| 1349 JavaScriptFrame* frame = it.frame(); | 1348 JavaScriptFrame* frame = it.frame(); |
| 1350 Context* context = Context::cast(frame->context()); | 1349 Context* context = Context::cast(frame->context()); |
| 1351 return Handle<Context>(context->native_context()); | 1350 return Handle<Context>(context->global_context()); |
| 1352 } | 1351 } |
| 1353 | 1352 |
| 1354 | 1353 |
| 1355 char* Isolate::ArchiveThread(char* to) { | 1354 char* Isolate::ArchiveThread(char* to) { |
| 1356 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { | 1355 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { |
| 1357 RuntimeProfiler::IsolateExitedJS(this); | 1356 RuntimeProfiler::IsolateExitedJS(this); |
| 1358 } | 1357 } |
| 1359 memcpy(to, reinterpret_cast<char*>(thread_local_top()), | 1358 memcpy(to, reinterpret_cast<char*>(thread_local_top()), |
| 1360 sizeof(ThreadLocalTop)); | 1359 sizeof(ThreadLocalTop)); |
| 1361 InitializeThreadLocal(); | 1360 InitializeThreadLocal(); |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 | 2032 |
| 2034 #ifdef DEBUG | 2033 #ifdef DEBUG |
| 2035 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2034 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2036 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2035 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2037 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2036 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2038 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2037 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2039 #undef ISOLATE_FIELD_OFFSET | 2038 #undef ISOLATE_FIELD_OFFSET |
| 2040 #endif | 2039 #endif |
| 2041 | 2040 |
| 2042 } } // namespace v8::internal | 2041 } } // namespace v8::internal |
| OLD | NEW |