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

Side by Side Diff: src/api.cc

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase again. Created 5 years, 3 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 | « no previous file | src/api-natives.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 4246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 Value); 4257 Value);
4258 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4258 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4259 auto self = Utils::OpenHandle(this); 4259 auto self = Utils::OpenHandle(this);
4260 auto recv_obj = Utils::OpenHandle(*recv); 4260 auto recv_obj = Utils::OpenHandle(*recv);
4261 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4261 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4262 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4262 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4263 i::Handle<i::JSFunction> fun; 4263 i::Handle<i::JSFunction> fun;
4264 if (self->IsJSFunction()) { 4264 if (self->IsJSFunction()) {
4265 fun = i::Handle<i::JSFunction>::cast(self); 4265 fun = i::Handle<i::JSFunction>::cast(self);
4266 } else { 4266 } else {
4267 i::Handle<i::Object> delegate; 4267 has_pending_exception =
4268 has_pending_exception = !i::Execution::TryGetFunctionDelegate(isolate, self) 4268 !i::Execution::GetFunctionDelegate(isolate, self).ToHandle(&fun);
4269 .ToHandle(&delegate);
4270 RETURN_ON_FAILED_EXECUTION(Value); 4269 RETURN_ON_FAILED_EXECUTION(Value);
4271 fun = i::Handle<i::JSFunction>::cast(delegate);
4272 recv_obj = self; 4270 recv_obj = self;
4273 } 4271 }
4274 Local<Value> result; 4272 Local<Value> result;
4275 has_pending_exception = 4273 has_pending_exception =
4276 !ToLocal<Value>( 4274 !ToLocal<Value>(
4277 i::Execution::Call(isolate, fun, recv_obj, argc, args, true), 4275 i::Execution::Call(isolate, fun, recv_obj, argc, args, true),
4278 &result); 4276 &result);
4279 RETURN_ON_FAILED_EXECUTION(Value); 4277 RETURN_ON_FAILED_EXECUTION(Value);
4280 RETURN_ESCAPED(result); 4278 RETURN_ESCAPED(result);
4281 } 4279 }
(...skipping 17 matching lines...) Expand all
4299 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4297 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4300 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4298 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4301 if (self->IsJSFunction()) { 4299 if (self->IsJSFunction()) {
4302 auto fun = i::Handle<i::JSFunction>::cast(self); 4300 auto fun = i::Handle<i::JSFunction>::cast(self);
4303 Local<Value> result; 4301 Local<Value> result;
4304 has_pending_exception = 4302 has_pending_exception =
4305 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result); 4303 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result);
4306 RETURN_ON_FAILED_EXECUTION(Value); 4304 RETURN_ON_FAILED_EXECUTION(Value);
4307 RETURN_ESCAPED(result); 4305 RETURN_ESCAPED(result);
4308 } 4306 }
4309 i::Handle<i::Object> delegate; 4307 i::Handle<i::JSFunction> fun;
4310 has_pending_exception = !i::Execution::TryGetConstructorDelegate( 4308 has_pending_exception =
4311 isolate, self).ToHandle(&delegate); 4309 !i::Execution::GetConstructorDelegate(isolate, self).ToHandle(&fun);
4312 RETURN_ON_FAILED_EXECUTION(Value); 4310 RETURN_ON_FAILED_EXECUTION(Value);
4313 if (!delegate->IsUndefined()) { 4311 Local<Value> result;
4314 auto fun = i::Handle<i::JSFunction>::cast(delegate); 4312 has_pending_exception = !ToLocal<Value>(
4315 Local<Value> result; 4313 i::Execution::Call(isolate, fun, self, argc, args), &result);
4316 has_pending_exception = 4314 RETURN_ON_FAILED_EXECUTION(Value);
4317 !ToLocal<Value>(i::Execution::Call(isolate, fun, self, argc, args), 4315 RETURN_ESCAPED(result);
4318 &result);
4319 RETURN_ON_FAILED_EXECUTION(Value);
4320 DCHECK(!delegate->IsUndefined());
4321 RETURN_ESCAPED(result);
4322 }
4323 return MaybeLocal<Value>();
4324 } 4316 }
4325 4317
4326 4318
4327 Local<v8::Value> Object::CallAsConstructor(int argc, 4319 Local<v8::Value> Object::CallAsConstructor(int argc,
4328 v8::Local<v8::Value> argv[]) { 4320 v8::Local<v8::Value> argv[]) {
4329 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4321 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4330 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 4322 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
4331 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); 4323 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value);
4332 } 4324 }
4333 4325
(...skipping 4079 matching lines...) Expand 10 before | Expand all | Expand 10 after
8413 Address callback_address = 8405 Address callback_address =
8414 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8406 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8415 VMState<EXTERNAL> state(isolate); 8407 VMState<EXTERNAL> state(isolate);
8416 ExternalCallbackScope call_scope(isolate, callback_address); 8408 ExternalCallbackScope call_scope(isolate, callback_address);
8417 callback(info); 8409 callback(info);
8418 } 8410 }
8419 8411
8420 8412
8421 } // namespace internal 8413 } // namespace internal
8422 } // namespace v8 8414 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/api-natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698