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/execution.h" | 5 #include "src/execution.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 isolate->factory()->undefined_value(), arraysize(argv), argv); \ | 431 isolate->factory()->undefined_value(), arraysize(argv), argv); \ |
432 } while (false) | 432 } while (false) |
433 | 433 |
434 | 434 |
435 MaybeHandle<Object> Execution::ToDetailString( | 435 MaybeHandle<Object> Execution::ToDetailString( |
436 Isolate* isolate, Handle<Object> obj) { | 436 Isolate* isolate, Handle<Object> obj) { |
437 RETURN_NATIVE_CALL(to_detail_string, { obj }); | 437 RETURN_NATIVE_CALL(to_detail_string, { obj }); |
438 } | 438 } |
439 | 439 |
440 | 440 |
441 MaybeHandle<Object> Execution::ToInteger( | |
442 Isolate* isolate, Handle<Object> obj) { | |
443 RETURN_NATIVE_CALL(to_integer, { obj }); | |
444 } | |
445 | |
446 | |
447 MaybeHandle<Object> Execution::ToLength( | |
448 Isolate* isolate, Handle<Object> obj) { | |
449 RETURN_NATIVE_CALL(to_length, { obj }); | |
450 } | |
451 | |
452 | |
453 MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) { | 441 MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) { |
454 Handle<Object> time_obj = isolate->factory()->NewNumber(time); | 442 Handle<Object> time_obj = isolate->factory()->NewNumber(time); |
455 RETURN_NATIVE_CALL(create_date, { time_obj }); | 443 RETURN_NATIVE_CALL(create_date, { time_obj }); |
456 } | 444 } |
457 | 445 |
458 | 446 |
459 #undef RETURN_NATIVE_CALL | 447 #undef RETURN_NATIVE_CALL |
460 | 448 |
461 | 449 |
462 MaybeHandle<Object> Execution::ToInt32(Isolate* isolate, Handle<Object> obj) { | |
463 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Object::ToNumber(obj), Object); | |
464 return isolate->factory()->NewNumberFromInt(DoubleToInt32(obj->Number())); | |
465 } | |
466 | |
467 | |
468 MaybeHandle<Object> Execution::ToObject(Isolate* isolate, Handle<Object> obj) { | 450 MaybeHandle<Object> Execution::ToObject(Isolate* isolate, Handle<Object> obj) { |
469 Handle<JSReceiver> receiver; | 451 Handle<JSReceiver> receiver; |
470 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { | 452 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { |
471 return receiver; | 453 return receiver; |
472 } | 454 } |
473 THROW_NEW_ERROR( | 455 THROW_NEW_ERROR( |
474 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject), Object); | 456 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject), Object); |
475 } | 457 } |
476 | 458 |
477 | 459 |
478 MaybeHandle<Object> Execution::ToUint32(Isolate* isolate, Handle<Object> obj) { | |
479 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Object::ToNumber(obj), Object); | |
480 return isolate->factory()->NewNumberFromUint(DoubleToUint32(obj->Number())); | |
481 } | |
482 | |
483 | |
484 MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, | 460 MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, |
485 Handle<String> flags) { | 461 Handle<String> flags) { |
486 Isolate* isolate = pattern->GetIsolate(); | 462 Isolate* isolate = pattern->GetIsolate(); |
487 Handle<JSFunction> function = Handle<JSFunction>( | 463 Handle<JSFunction> function = Handle<JSFunction>( |
488 isolate->native_context()->regexp_function()); | 464 isolate->native_context()->regexp_function()); |
489 Handle<Object> re_obj; | 465 Handle<Object> re_obj; |
490 ASSIGN_RETURN_ON_EXCEPTION( | 466 ASSIGN_RETURN_ON_EXCEPTION( |
491 isolate, re_obj, | 467 isolate, re_obj, |
492 RegExpImpl::CreateRegExpLiteral(function, pattern, flags), | 468 RegExpImpl::CreateRegExpLiteral(function, pattern, flags), |
493 JSRegExp); | 469 JSRegExp); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 525 |
550 isolate_->counters()->stack_interrupts()->Increment(); | 526 isolate_->counters()->stack_interrupts()->Increment(); |
551 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 527 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
552 isolate_->runtime_profiler()->OptimizeNow(); | 528 isolate_->runtime_profiler()->OptimizeNow(); |
553 | 529 |
554 return isolate_->heap()->undefined_value(); | 530 return isolate_->heap()->undefined_value(); |
555 } | 531 } |
556 | 532 |
557 } // namespace internal | 533 } // namespace internal |
558 } // namespace v8 | 534 } // namespace v8 |
OLD | NEW |