Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: src/messages.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/lookup.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/messages.h" 5 #include "src/messages.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/execution.h" 8 #include "src/execution.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/keys.h" 10 #include "src/keys.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 v8::NeanderArray global_listeners(isolate->factory()->message_listeners()); 123 v8::NeanderArray global_listeners(isolate->factory()->message_listeners());
124 int global_length = global_listeners.length(); 124 int global_length = global_listeners.length();
125 if (global_length == 0) { 125 if (global_length == 0) {
126 DefaultMessageReport(isolate, loc, message); 126 DefaultMessageReport(isolate, loc, message);
127 if (isolate->has_scheduled_exception()) { 127 if (isolate->has_scheduled_exception()) {
128 isolate->clear_scheduled_exception(); 128 isolate->clear_scheduled_exception();
129 } 129 }
130 } else { 130 } else {
131 for (int i = 0; i < global_length; i++) { 131 for (int i = 0; i < global_length; i++) {
132 HandleScope scope(isolate); 132 HandleScope scope(isolate);
133 if (global_listeners.get(i)->IsUndefined()) continue; 133 if (global_listeners.get(i)->IsUndefined(isolate)) continue;
134 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); 134 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i)));
135 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0))); 135 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0)));
136 v8::MessageCallback callback = 136 v8::MessageCallback callback =
137 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); 137 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address());
138 Handle<Object> callback_data(listener.get(1), isolate); 138 Handle<Object> callback_data(listener.get(1), isolate);
139 { 139 {
140 // Do not allow exceptions to propagate. 140 // Do not allow exceptions to propagate.
141 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 141 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
142 callback(api_message_obj, callback_data->IsUndefined() 142 callback(api_message_obj, callback_data->IsUndefined(isolate)
143 ? api_exception_obj 143 ? api_exception_obj
144 : v8::Utils::ToLocal(callback_data)); 144 : v8::Utils::ToLocal(callback_data));
145 } 145 }
146 if (isolate->has_scheduled_exception()) { 146 if (isolate->has_scheduled_exception()) {
147 isolate->clear_scheduled_exception(); 147 isolate->clear_scheduled_exception();
148 } 148 }
149 } 149 }
150 } 150 }
151 } 151 }
152 152
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (accessors->IsAccessorPair()) { 244 if (accessors->IsAccessorPair()) {
245 Handle<AccessorPair> pair = Handle<AccessorPair>::cast(accessors); 245 Handle<AccessorPair> pair = Handle<AccessorPair>::cast(accessors);
246 return pair->getter() == *fun || pair->setter() == *fun; 246 return pair->getter() == *fun || pair->setter() == *fun;
247 } 247 }
248 } 248 }
249 return false; 249 return false;
250 } 250 }
251 251
252 252
253 Handle<Object> CallSite::GetMethodName() { 253 Handle<Object> CallSite::GetMethodName() {
254 if (!IsJavaScript() || receiver_->IsNull() || receiver_->IsUndefined()) { 254 if (!IsJavaScript() || receiver_->IsNull() ||
255 receiver_->IsUndefined(isolate_)) {
255 return isolate_->factory()->null_value(); 256 return isolate_->factory()->null_value();
256 } 257 }
257 Handle<JSReceiver> receiver = 258 Handle<JSReceiver> receiver =
258 Object::ToObject(isolate_, receiver_).ToHandleChecked(); 259 Object::ToObject(isolate_, receiver_).ToHandleChecked();
259 if (!receiver->IsJSObject()) { 260 if (!receiver->IsJSObject()) {
260 return isolate_->factory()->null_value(); 261 return isolate_->factory()->null_value();
261 } 262 }
262 263
263 Handle<JSObject> obj = Handle<JSObject>::cast(receiver); 264 Handle<JSObject> obj = Handle<JSObject>::cast(receiver);
264 Handle<Object> function_name(fun_->shared()->name(), isolate_); 265 Handle<Object> function_name(fun_->shared()->name(), isolate_);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if (!IsJavaScript()) return false; 338 if (!IsJavaScript()) return false;
338 Handle<Object> script(fun_->shared()->script(), isolate_); 339 Handle<Object> script(fun_->shared()->script(), isolate_);
339 return script->IsScript() && 340 return script->IsScript() &&
340 Handle<Script>::cast(script)->type() == Script::TYPE_NATIVE; 341 Handle<Script>::cast(script)->type() == Script::TYPE_NATIVE;
341 } 342 }
342 343
343 344
344 bool CallSite::IsToplevel() { 345 bool CallSite::IsToplevel() {
345 if (IsWasm()) return false; 346 if (IsWasm()) return false;
346 return receiver_->IsJSGlobalProxy() || receiver_->IsNull() || 347 return receiver_->IsJSGlobalProxy() || receiver_->IsNull() ||
347 receiver_->IsUndefined(); 348 receiver_->IsUndefined(isolate_);
348 } 349 }
349 350
350 351
351 bool CallSite::IsEval() { 352 bool CallSite::IsEval() {
352 if (!IsJavaScript()) return false; 353 if (!IsJavaScript()) return false;
353 Handle<Object> script(fun_->shared()->script(), isolate_); 354 Handle<Object> script(fun_->shared()->script(), isolate_);
354 return script->IsScript() && 355 return script->IsScript() &&
355 Handle<Script>::cast(script)->compilation_type() == 356 Handle<Script>::cast(script)->compilation_type() ==
356 Script::COMPILATION_TYPE_EVAL; 357 Script::COMPILATION_TYPE_EVAL;
357 } 358 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 builder.AppendCharacter(*c); 444 builder.AppendCharacter(*c);
444 } 445 }
445 } 446 }
446 447
447 return builder.Finish(); 448 return builder.Finish();
448 } 449 }
449 450
450 451
451 } // namespace internal 452 } // namespace internal
452 } // namespace v8 453 } // namespace v8
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698