| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 HandleScope scope(isolate); | 49 HandleScope scope(isolate); |
| 50 DCHECK(args.length() == 0); | 50 DCHECK(args.length() == 0); |
| 51 isolate->RunMicrotasks(); | 51 isolate->RunMicrotasks(); |
| 52 return isolate->heap()->undefined_value(); | 52 return isolate->heap()->undefined_value(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 RUNTIME_FUNCTION(Runtime_DeliverObservationChangeRecords) { | 56 RUNTIME_FUNCTION(Runtime_DeliverObservationChangeRecords) { |
| 57 HandleScope scope(isolate); | 57 HandleScope scope(isolate); |
| 58 DCHECK(args.length() == 2); | 58 DCHECK(args.length() == 2); |
| 59 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); | 59 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callback, 0); |
| 60 CONVERT_ARG_HANDLE_CHECKED(Object, argument, 1); | 60 CONVERT_ARG_HANDLE_CHECKED(Object, argument, 1); |
| 61 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate)); | 61 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate)); |
| 62 // We should send a message on uncaught exception thrown during | 62 // We should send a message on uncaught exception thrown during |
| 63 // Object.observe delivery while not interrupting further delivery, thus | 63 // Object.observe delivery while not interrupting further delivery, thus |
| 64 // we make a call inside a verbose TryCatch. | 64 // we make a call inside a verbose TryCatch. |
| 65 catcher.SetVerbose(true); | 65 catcher.SetVerbose(true); |
| 66 Handle<Object> argv[] = {argument}; | 66 Handle<Object> argv[] = {argument}; |
| 67 | 67 |
| 68 // If we are in step-in mode, flood the handler. | 68 // If we are in step-in mode, flood the handler. |
| 69 isolate->debug()->EnableStepIn(); | 69 isolate->debug()->EnableStepIn(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 static bool ContextsHaveSameOrigin(Handle<Context> context1, | 90 static bool ContextsHaveSameOrigin(Handle<Context> context1, |
| 91 Handle<Context> context2) { | 91 Handle<Context> context2) { |
| 92 return context1->security_token() == context2->security_token(); | 92 return context1->security_token() == context2->security_token(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { | 96 RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { |
| 97 HandleScope scope(isolate); | 97 HandleScope scope(isolate); |
| 98 DCHECK(args.length() == 3); | 98 DCHECK(args.length() == 3); |
| 99 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 99 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, observer, 0); |
| 100 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 100 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
| 101 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); | 101 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); |
| 102 | 102 |
| 103 Handle<Context> observer_context(observer->context()->native_context()); | 103 while (observer->IsJSBoundFunction()) { |
| 104 observer = handle( |
| 105 Handle<JSBoundFunction>::cast(observer)->bound_target_function()); |
| 106 } |
| 107 if (!observer->IsJSFunction()) return isolate->heap()->false_value(); |
| 108 |
| 109 Handle<Context> observer_context( |
| 110 Handle<JSFunction>::cast(observer)->context()->native_context()); |
| 104 Handle<Context> object_context(object->GetCreationContext()); | 111 Handle<Context> object_context(object->GetCreationContext()); |
| 105 Handle<Context> record_context(record->GetCreationContext()); | 112 Handle<Context> record_context(record->GetCreationContext()); |
| 106 | 113 |
| 107 return isolate->heap()->ToBoolean( | 114 return isolate->heap()->ToBoolean( |
| 108 ContextsHaveSameOrigin(object_context, observer_context) && | 115 ContextsHaveSameOrigin(object_context, observer_context) && |
| 109 ContextsHaveSameOrigin(object_context, record_context)); | 116 ContextsHaveSameOrigin(object_context, record_context)); |
| 110 } | 117 } |
| 111 | 118 |
| 112 | 119 |
| 113 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { | 120 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 144 RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) { | 151 RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) { |
| 145 HandleScope scope(isolate); | 152 HandleScope scope(isolate); |
| 146 DCHECK(args.length() == 1); | 153 DCHECK(args.length() == 1); |
| 147 CONVERT_ARG_HANDLE_CHECKED(JSObject, object_info, 0); | 154 CONVERT_ARG_HANDLE_CHECKED(JSObject, object_info, 0); |
| 148 | 155 |
| 149 Handle<Context> context(object_info->GetCreationContext(), isolate); | 156 Handle<Context> context(object_info->GetCreationContext(), isolate); |
| 150 return context->native_object_notifier_perform_change(); | 157 return context->native_object_notifier_perform_change(); |
| 151 } | 158 } |
| 152 } // namespace internal | 159 } // namespace internal |
| 153 } // namespace v8 | 160 } // namespace v8 |
| OLD | NEW |