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

Side by Side Diff: src/api.cc

Issue 1353723002: [runtime] Initial step towards switching Execution::Call to callable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Handle sloppy mode api functions correctly. 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/arm/builtins-arm.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 4236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4247 i::Handle<i::JSFunction> fun; 4247 i::Handle<i::JSFunction> fun;
4248 if (self->IsJSFunction()) { 4248 if (self->IsJSFunction()) {
4249 fun = i::Handle<i::JSFunction>::cast(self); 4249 fun = i::Handle<i::JSFunction>::cast(self);
4250 } else { 4250 } else {
4251 has_pending_exception = 4251 has_pending_exception =
4252 !i::Execution::GetFunctionDelegate(isolate, self).ToHandle(&fun); 4252 !i::Execution::GetFunctionDelegate(isolate, self).ToHandle(&fun);
4253 RETURN_ON_FAILED_EXECUTION(Value); 4253 RETURN_ON_FAILED_EXECUTION(Value);
4254 recv_obj = self; 4254 recv_obj = self;
4255 } 4255 }
4256 Local<Value> result; 4256 Local<Value> result;
4257 has_pending_exception = 4257 has_pending_exception = !ToLocal<Value>(
4258 !ToLocal<Value>( 4258 i::Execution::Call(isolate, fun, recv_obj, argc, args), &result);
4259 i::Execution::Call(isolate, fun, recv_obj, argc, args, true),
4260 &result);
4261 RETURN_ON_FAILED_EXECUTION(Value); 4259 RETURN_ON_FAILED_EXECUTION(Value);
4262 RETURN_ESCAPED(result); 4260 RETURN_ESCAPED(result);
4263 } 4261 }
4264 4262
4265 4263
4266 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, 4264 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc,
4267 v8::Local<v8::Value> argv[]) { 4265 v8::Local<v8::Value> argv[]) {
4268 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4266 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4269 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 4267 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
4270 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), 4268 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
4358 MaybeLocal<v8::Value> Function::Call(Local<Context> context, 4356 MaybeLocal<v8::Value> Function::Call(Local<Context> context,
4359 v8::Local<v8::Value> recv, int argc, 4357 v8::Local<v8::Value> recv, int argc,
4360 v8::Local<v8::Value> argv[]) { 4358 v8::Local<v8::Value> argv[]) {
4361 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); 4359 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value);
4362 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); 4360 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
4363 auto self = Utils::OpenHandle(this); 4361 auto self = Utils::OpenHandle(this);
4364 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 4362 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4365 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); 4363 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
4366 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4364 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4367 Local<Value> result; 4365 Local<Value> result;
4368 has_pending_exception = 4366 has_pending_exception = !ToLocal<Value>(
4369 !ToLocal<Value>( 4367 i::Execution::Call(isolate, self, recv_obj, argc, args), &result);
4370 i::Execution::Call(isolate, self, recv_obj, argc, args, true),
4371 &result);
4372 RETURN_ON_FAILED_EXECUTION(Value); 4368 RETURN_ON_FAILED_EXECUTION(Value);
4373 RETURN_ESCAPED(result); 4369 RETURN_ESCAPED(result);
4374 } 4370 }
4375 4371
4376 4372
4377 Local<v8::Value> Function::Call(v8::Local<v8::Value> recv, int argc, 4373 Local<v8::Value> Function::Call(v8::Local<v8::Value> recv, int argc,
4378 v8::Local<v8::Value> argv[]) { 4374 v8::Local<v8::Value> argv[]) {
4379 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4375 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4380 RETURN_TO_LOCAL_UNCHECKED(Call(context, recv, argc, argv), Value); 4376 RETURN_TO_LOCAL_UNCHECKED(Call(context, recv, argc, argv), Value);
4381 } 4377 }
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
6134 } 6130 }
6135 6131
6136 6132
6137 MaybeLocal<Value> Map::Get(Local<Context> context, Local<Value> key) { 6133 MaybeLocal<Value> Map::Get(Local<Context> context, Local<Value> key) {
6138 PREPARE_FOR_EXECUTION(context, "Map::Get", Value); 6134 PREPARE_FOR_EXECUTION(context, "Map::Get", Value);
6139 auto self = Utils::OpenHandle(this); 6135 auto self = Utils::OpenHandle(this);
6140 Local<Value> result; 6136 Local<Value> result;
6141 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; 6137 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
6142 has_pending_exception = 6138 has_pending_exception =
6143 !ToLocal<Value>(i::Execution::Call(isolate, isolate->map_get(), self, 6139 !ToLocal<Value>(i::Execution::Call(isolate, isolate->map_get(), self,
6144 arraysize(argv), argv, false), 6140 arraysize(argv), argv),
6145 &result); 6141 &result);
6146 RETURN_ON_FAILED_EXECUTION(Value); 6142 RETURN_ON_FAILED_EXECUTION(Value);
6147 RETURN_ESCAPED(result); 6143 RETURN_ESCAPED(result);
6148 } 6144 }
6149 6145
6150 6146
6151 MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key, 6147 MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key,
6152 Local<Value> value) { 6148 Local<Value> value) {
6153 PREPARE_FOR_EXECUTION(context, "Map::Set", Map); 6149 PREPARE_FOR_EXECUTION(context, "Map::Set", Map);
6154 auto self = Utils::OpenHandle(this); 6150 auto self = Utils::OpenHandle(this);
6155 i::Handle<i::Object> result; 6151 i::Handle<i::Object> result;
6156 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), 6152 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key),
6157 Utils::OpenHandle(*value)}; 6153 Utils::OpenHandle(*value)};
6158 has_pending_exception = 6154 has_pending_exception = !i::Execution::Call(isolate, isolate->map_set(), self,
6159 !i::Execution::Call(isolate, isolate->map_set(), self, arraysize(argv), 6155 arraysize(argv), argv)
6160 argv, false).ToHandle(&result); 6156 .ToHandle(&result);
6161 RETURN_ON_FAILED_EXECUTION(Map); 6157 RETURN_ON_FAILED_EXECUTION(Map);
6162 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); 6158 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result)));
6163 } 6159 }
6164 6160
6165 6161
6166 Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) { 6162 Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) {
6167 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Has", bool); 6163 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Has", bool);
6168 auto self = Utils::OpenHandle(this); 6164 auto self = Utils::OpenHandle(this);
6169 i::Handle<i::Object> result; 6165 i::Handle<i::Object> result;
6170 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; 6166 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
6171 has_pending_exception = 6167 has_pending_exception = !i::Execution::Call(isolate, isolate->map_has(), self,
6172 !i::Execution::Call(isolate, isolate->map_has(), self, arraysize(argv), 6168 arraysize(argv), argv)
6173 argv, false).ToHandle(&result); 6169 .ToHandle(&result);
6174 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 6170 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6175 return Just(result->IsTrue()); 6171 return Just(result->IsTrue());
6176 } 6172 }
6177 6173
6178 6174
6179 Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) { 6175 Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) {
6180 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Delete", bool); 6176 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Delete", bool);
6181 auto self = Utils::OpenHandle(this); 6177 auto self = Utils::OpenHandle(this);
6182 i::Handle<i::Object> result; 6178 i::Handle<i::Object> result;
6183 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; 6179 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
6184 has_pending_exception = 6180 has_pending_exception = !i::Execution::Call(isolate, isolate->map_delete(),
6185 !i::Execution::Call(isolate, isolate->map_delete(), self, arraysize(argv), 6181 self, arraysize(argv), argv)
6186 argv, false).ToHandle(&result); 6182 .ToHandle(&result);
6187 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 6183 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6188 return Just(result->IsTrue()); 6184 return Just(result->IsTrue());
6189 } 6185 }
6190 6186
6191 6187
6192 Local<Array> Map::AsArray() const { 6188 Local<Array> Map::AsArray() const {
6193 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); 6189 i::Handle<i::JSMap> obj = Utils::OpenHandle(this);
6194 i::Isolate* isolate = obj->GetIsolate(); 6190 i::Isolate* isolate = obj->GetIsolate();
6195 i::Factory* factory = isolate->factory(); 6191 i::Factory* factory = isolate->factory();
6196 LOG_API(isolate, "Map::AsArray"); 6192 LOG_API(isolate, "Map::AsArray");
(...skipping 16 matching lines...) Expand all
6213 MaybeLocal<Map> Map::FromArray(Local<Context> context, Local<Array> array) { 6209 MaybeLocal<Map> Map::FromArray(Local<Context> context, Local<Array> array) {
6214 PREPARE_FOR_EXECUTION(context, "Map::FromArray", Map); 6210 PREPARE_FOR_EXECUTION(context, "Map::FromArray", Map);
6215 if (array->Length() % 2 != 0) { 6211 if (array->Length() % 2 != 0) {
6216 return MaybeLocal<Map>(); 6212 return MaybeLocal<Map>();
6217 } 6213 }
6218 i::Handle<i::Object> result; 6214 i::Handle<i::Object> result;
6219 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)}; 6215 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)};
6220 has_pending_exception = 6216 has_pending_exception =
6221 !i::Execution::Call(isolate, isolate->map_from_array(), 6217 !i::Execution::Call(isolate, isolate->map_from_array(),
6222 isolate->factory()->undefined_value(), 6218 isolate->factory()->undefined_value(),
6223 arraysize(argv), argv, false).ToHandle(&result); 6219 arraysize(argv), argv)
6220 .ToHandle(&result);
6224 RETURN_ON_FAILED_EXECUTION(Map); 6221 RETURN_ON_FAILED_EXECUTION(Map);
6225 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); 6222 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result)));
6226 } 6223 }
6227 6224
6228 6225
6229 Local<v8::Set> v8::Set::New(Isolate* isolate) { 6226 Local<v8::Set> v8::Set::New(Isolate* isolate) {
6230 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6227 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6231 LOG_API(i_isolate, "Set::New"); 6228 LOG_API(i_isolate, "Set::New");
6232 ENTER_V8(i_isolate); 6229 ENTER_V8(i_isolate);
6233 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); 6230 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet();
(...skipping 14 matching lines...) Expand all
6248 ENTER_V8(isolate); 6245 ENTER_V8(isolate);
6249 i::JSSet::Clear(self); 6246 i::JSSet::Clear(self);
6250 } 6247 }
6251 6248
6252 6249
6253 MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) { 6250 MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) {
6254 PREPARE_FOR_EXECUTION(context, "Set::Add", Set); 6251 PREPARE_FOR_EXECUTION(context, "Set::Add", Set);
6255 auto self = Utils::OpenHandle(this); 6252 auto self = Utils::OpenHandle(this);
6256 i::Handle<i::Object> result; 6253 i::Handle<i::Object> result;
6257 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; 6254 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
6258 has_pending_exception = 6255 has_pending_exception = !i::Execution::Call(isolate, isolate->set_add(), self,
6259 !i::Execution::Call(isolate, isolate->set_add(), self, arraysize(argv), 6256 arraysize(argv), argv)
6260 argv, false).ToHandle(&result); 6257 .ToHandle(&result);
6261 RETURN_ON_FAILED_EXECUTION(Set); 6258 RETURN_ON_FAILED_EXECUTION(Set);
6262 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); 6259 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result)));
6263 } 6260 }
6264 6261
6265 6262
6266 Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) { 6263 Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) {
6267 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Has", bool); 6264 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Has", bool);
6268 auto self = Utils::OpenHandle(this); 6265 auto self = Utils::OpenHandle(this);
6269 i::Handle<i::Object> result; 6266 i::Handle<i::Object> result;
6270 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; 6267 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
6271 has_pending_exception = 6268 has_pending_exception = !i::Execution::Call(isolate, isolate->set_has(), self,
6272 !i::Execution::Call(isolate, isolate->set_has(), self, arraysize(argv), 6269 arraysize(argv), argv)
6273 argv, false).ToHandle(&result); 6270 .ToHandle(&result);
6274 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 6271 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6275 return Just(result->IsTrue()); 6272 return Just(result->IsTrue());
6276 } 6273 }
6277 6274
6278 6275
6279 Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) { 6276 Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) {
6280 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Delete", bool); 6277 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Delete", bool);
6281 auto self = Utils::OpenHandle(this); 6278 auto self = Utils::OpenHandle(this);
6282 i::Handle<i::Object> result; 6279 i::Handle<i::Object> result;
6283 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; 6280 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
6284 has_pending_exception = 6281 has_pending_exception = !i::Execution::Call(isolate, isolate->set_delete(),
6285 !i::Execution::Call(isolate, isolate->set_delete(), self, arraysize(argv), 6282 self, arraysize(argv), argv)
6286 argv, false).ToHandle(&result); 6283 .ToHandle(&result);
6287 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 6284 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6288 return Just(result->IsTrue()); 6285 return Just(result->IsTrue());
6289 } 6286 }
6290 6287
6291 6288
6292 Local<Array> Set::AsArray() const { 6289 Local<Array> Set::AsArray() const {
6293 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); 6290 i::Handle<i::JSSet> obj = Utils::OpenHandle(this);
6294 i::Isolate* isolate = obj->GetIsolate(); 6291 i::Isolate* isolate = obj->GetIsolate();
6295 i::Factory* factory = isolate->factory(); 6292 i::Factory* factory = isolate->factory();
6296 LOG_API(isolate, "Set::AsArray"); 6293 LOG_API(isolate, "Set::AsArray");
(...skipping 13 matching lines...) Expand all
6310 } 6307 }
6311 6308
6312 6309
6313 MaybeLocal<Set> Set::FromArray(Local<Context> context, Local<Array> array) { 6310 MaybeLocal<Set> Set::FromArray(Local<Context> context, Local<Array> array) {
6314 PREPARE_FOR_EXECUTION(context, "Set::FromArray", Set); 6311 PREPARE_FOR_EXECUTION(context, "Set::FromArray", Set);
6315 i::Handle<i::Object> result; 6312 i::Handle<i::Object> result;
6316 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)}; 6313 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)};
6317 has_pending_exception = 6314 has_pending_exception =
6318 !i::Execution::Call(isolate, isolate->set_from_array(), 6315 !i::Execution::Call(isolate, isolate->set_from_array(),
6319 isolate->factory()->undefined_value(), 6316 isolate->factory()->undefined_value(),
6320 arraysize(argv), argv, false).ToHandle(&result); 6317 arraysize(argv), argv)
6318 .ToHandle(&result);
6321 RETURN_ON_FAILED_EXECUTION(Set); 6319 RETURN_ON_FAILED_EXECUTION(Set);
6322 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); 6320 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result)));
6323 } 6321 }
6324 6322
6325 6323
6326 bool Value::IsPromise() const { 6324 bool Value::IsPromise() const {
6327 auto self = Utils::OpenHandle(this); 6325 auto self = Utils::OpenHandle(this);
6328 return i::Object::IsPromise(self); 6326 return i::Object::IsPromise(self);
6329 } 6327 }
6330 6328
6331 6329
6332 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { 6330 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) {
6333 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); 6331 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver);
6334 i::Handle<i::Object> result; 6332 i::Handle<i::Object> result;
6335 has_pending_exception = !i::Execution::Call( 6333 has_pending_exception =
6336 isolate, 6334 !i::Execution::Call(isolate, isolate->promise_create(),
6337 isolate->promise_create(), 6335 isolate->factory()->undefined_value(), 0, NULL)
6338 isolate->factory()->undefined_value(), 6336 .ToHandle(&result);
6339 0, NULL,
6340 false).ToHandle(&result);
6341 RETURN_ON_FAILED_EXECUTION(Promise::Resolver); 6337 RETURN_ON_FAILED_EXECUTION(Promise::Resolver);
6342 RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result))); 6338 RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result)));
6343 } 6339 }
6344 6340
6345 6341
6346 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { 6342 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) {
6347 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), 6343 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()),
6348 Promise::Resolver); 6344 Promise::Resolver);
6349 } 6345 }
6350 6346
6351 6347
6352 Local<Promise> Promise::Resolver::GetPromise() { 6348 Local<Promise> Promise::Resolver::GetPromise() {
6353 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); 6349 i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
6354 return Local<Promise>::Cast(Utils::ToLocal(promise)); 6350 return Local<Promise>::Cast(Utils::ToLocal(promise));
6355 } 6351 }
6356 6352
6357 6353
6358 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, 6354 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
6359 Local<Value> value) { 6355 Local<Value> value) {
6360 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); 6356 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool);
6361 auto self = Utils::OpenHandle(this); 6357 auto self = Utils::OpenHandle(this);
6362 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; 6358 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)};
6363 has_pending_exception = i::Execution::Call( 6359 has_pending_exception =
6364 isolate, 6360 i::Execution::Call(isolate, isolate->promise_resolve(),
6365 isolate->promise_resolve(), 6361 isolate->factory()->undefined_value(), arraysize(argv),
6366 isolate->factory()->undefined_value(), 6362 argv)
6367 arraysize(argv), argv, 6363 .is_null();
6368 false).is_null();
6369 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 6364 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6370 return Just(true); 6365 return Just(true);
6371 } 6366 }
6372 6367
6373 6368
6374 void Promise::Resolver::Resolve(Local<Value> value) { 6369 void Promise::Resolver::Resolve(Local<Value> value) {
6375 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6370 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6376 USE(Resolve(context, value)); 6371 USE(Resolve(context, value));
6377 } 6372 }
6378 6373
6379 6374
6380 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, 6375 Maybe<bool> Promise::Resolver::Reject(Local<Context> context,
6381 Local<Value> value) { 6376 Local<Value> value) {
6382 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); 6377 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool);
6383 auto self = Utils::OpenHandle(this); 6378 auto self = Utils::OpenHandle(this);
6384 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; 6379 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)};
6385 has_pending_exception = i::Execution::Call( 6380 has_pending_exception =
6386 isolate, 6381 i::Execution::Call(isolate, isolate->promise_reject(),
6387 isolate->promise_reject(), 6382 isolate->factory()->undefined_value(), arraysize(argv),
6388 isolate->factory()->undefined_value(), 6383 argv)
6389 arraysize(argv), argv, 6384 .is_null();
6390 false).is_null();
6391 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 6385 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
6392 return Just(true); 6386 return Just(true);
6393 } 6387 }
6394 6388
6395 6389
6396 void Promise::Resolver::Reject(Local<Value> value) { 6390 void Promise::Resolver::Reject(Local<Value> value) {
6397 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6391 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6398 USE(Reject(context, value)); 6392 USE(Reject(context, value));
6399 } 6393 }
6400 6394
6401 6395
6402 MaybeLocal<Promise> Promise::Chain(Local<Context> context, 6396 MaybeLocal<Promise> Promise::Chain(Local<Context> context,
6403 Local<Function> handler) { 6397 Local<Function> handler) {
6404 PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise); 6398 PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise);
6405 auto self = Utils::OpenHandle(this); 6399 auto self = Utils::OpenHandle(this);
6406 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; 6400 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)};
6407 i::Handle<i::Object> result; 6401 i::Handle<i::Object> result;
6408 has_pending_exception = 6402 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(),
6409 !i::Execution::Call(isolate, isolate->promise_chain(), self, 6403 self, arraysize(argv), argv)
6410 arraysize(argv), argv, false).ToHandle(&result); 6404 .ToHandle(&result);
6411 RETURN_ON_FAILED_EXECUTION(Promise); 6405 RETURN_ON_FAILED_EXECUTION(Promise);
6412 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); 6406 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result)));
6413 } 6407 }
6414 6408
6415 6409
6416 Local<Promise> Promise::Chain(Local<Function> handler) { 6410 Local<Promise> Promise::Chain(Local<Function> handler) {
6417 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6411 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6418 RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise); 6412 RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise);
6419 } 6413 }
6420 6414
6421 6415
6422 MaybeLocal<Promise> Promise::Catch(Local<Context> context, 6416 MaybeLocal<Promise> Promise::Catch(Local<Context> context,
6423 Local<Function> handler) { 6417 Local<Function> handler) {
6424 PREPARE_FOR_EXECUTION(context, "Promise::Catch", Promise); 6418 PREPARE_FOR_EXECUTION(context, "Promise::Catch", Promise);
6425 auto self = Utils::OpenHandle(this); 6419 auto self = Utils::OpenHandle(this);
6426 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; 6420 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
6427 i::Handle<i::Object> result; 6421 i::Handle<i::Object> result;
6428 has_pending_exception = 6422 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(),
6429 !i::Execution::Call(isolate, isolate->promise_catch(), self, 6423 self, arraysize(argv), argv)
6430 arraysize(argv), argv, false).ToHandle(&result); 6424 .ToHandle(&result);
6431 RETURN_ON_FAILED_EXECUTION(Promise); 6425 RETURN_ON_FAILED_EXECUTION(Promise);
6432 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); 6426 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result)));
6433 } 6427 }
6434 6428
6435 6429
6436 Local<Promise> Promise::Catch(Local<Function> handler) { 6430 Local<Promise> Promise::Catch(Local<Function> handler) {
6437 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6431 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6438 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); 6432 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise);
6439 } 6433 }
6440 6434
6441 6435
6442 MaybeLocal<Promise> Promise::Then(Local<Context> context, 6436 MaybeLocal<Promise> Promise::Then(Local<Context> context,
6443 Local<Function> handler) { 6437 Local<Function> handler) {
6444 PREPARE_FOR_EXECUTION(context, "Promise::Then", Promise); 6438 PREPARE_FOR_EXECUTION(context, "Promise::Then", Promise);
6445 auto self = Utils::OpenHandle(this); 6439 auto self = Utils::OpenHandle(this);
6446 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; 6440 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
6447 i::Handle<i::Object> result; 6441 i::Handle<i::Object> result;
6448 has_pending_exception = 6442 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_then(),
6449 !i::Execution::Call(isolate, isolate->promise_then(), self, 6443 self, arraysize(argv), argv)
6450 arraysize(argv), argv, false).ToHandle(&result); 6444 .ToHandle(&result);
6451 RETURN_ON_FAILED_EXECUTION(Promise); 6445 RETURN_ON_FAILED_EXECUTION(Promise);
6452 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); 6446 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result)));
6453 } 6447 }
6454 6448
6455 6449
6456 Local<Promise> Promise::Then(Local<Function> handler) { 6450 Local<Promise> Promise::Then(Local<Function> handler) {
6457 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6451 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6458 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); 6452 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise);
6459 } 6453 }
6460 6454
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
8387 Address callback_address = 8381 Address callback_address =
8388 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8382 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8389 VMState<EXTERNAL> state(isolate); 8383 VMState<EXTERNAL> state(isolate);
8390 ExternalCallbackScope call_scope(isolate, callback_address); 8384 ExternalCallbackScope call_scope(isolate, callback_address);
8391 callback(info); 8385 callback(info);
8392 } 8386 }
8393 8387
8394 8388
8395 } // namespace internal 8389 } // namespace internal
8396 } // namespace v8 8390 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/arm/builtins-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698