| 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/messages.h" | 10 #include "src/messages.h" |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 // --- C a l l s t o n a t i v e s --- | 537 // --- C a l l s t o n a t i v e s --- |
| 538 | 538 |
| 539 #define RETURN_NATIVE_CALL(name, args) \ | 539 #define RETURN_NATIVE_CALL(name, args) \ |
| 540 do { \ | 540 do { \ |
| 541 Handle<Object> argv[] = args; \ | 541 Handle<Object> argv[] = args; \ |
| 542 return Call(isolate, isolate->name##_fun(), \ | 542 return Call(isolate, isolate->name##_fun(), \ |
| 543 isolate->factory()->undefined_value(), arraysize(argv), argv); \ | 543 isolate->factory()->undefined_value(), arraysize(argv), argv); \ |
| 544 } while (false) | 544 } while (false) |
| 545 | 545 |
| 546 | 546 |
| 547 MaybeHandle<Object> Execution::ToNumber( | |
| 548 Isolate* isolate, Handle<Object> obj) { | |
| 549 RETURN_NATIVE_CALL(to_number, { obj }); | |
| 550 } | |
| 551 | |
| 552 | |
| 553 MaybeHandle<Object> Execution::ToString( | |
| 554 Isolate* isolate, Handle<Object> obj) { | |
| 555 RETURN_NATIVE_CALL(to_string, { obj }); | |
| 556 } | |
| 557 | |
| 558 | |
| 559 MaybeHandle<Object> Execution::ToDetailString( | 547 MaybeHandle<Object> Execution::ToDetailString( |
| 560 Isolate* isolate, Handle<Object> obj) { | 548 Isolate* isolate, Handle<Object> obj) { |
| 561 RETURN_NATIVE_CALL(to_detail_string, { obj }); | 549 RETURN_NATIVE_CALL(to_detail_string, { obj }); |
| 562 } | 550 } |
| 563 | 551 |
| 564 | 552 |
| 565 MaybeHandle<Object> Execution::ToInteger( | 553 MaybeHandle<Object> Execution::ToInteger( |
| 566 Isolate* isolate, Handle<Object> obj) { | 554 Isolate* isolate, Handle<Object> obj) { |
| 567 RETURN_NATIVE_CALL(to_integer, { obj }); | 555 RETURN_NATIVE_CALL(to_integer, { obj }); |
| 568 } | 556 } |
| 569 | 557 |
| 570 | 558 |
| 571 MaybeHandle<Object> Execution::ToLength( | 559 MaybeHandle<Object> Execution::ToLength( |
| 572 Isolate* isolate, Handle<Object> obj) { | 560 Isolate* isolate, Handle<Object> obj) { |
| 573 RETURN_NATIVE_CALL(to_length, { obj }); | 561 RETURN_NATIVE_CALL(to_length, { obj }); |
| 574 } | 562 } |
| 575 | 563 |
| 576 | 564 |
| 577 MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) { | 565 MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) { |
| 578 Handle<Object> time_obj = isolate->factory()->NewNumber(time); | 566 Handle<Object> time_obj = isolate->factory()->NewNumber(time); |
| 579 RETURN_NATIVE_CALL(create_date, { time_obj }); | 567 RETURN_NATIVE_CALL(create_date, { time_obj }); |
| 580 } | 568 } |
| 581 | 569 |
| 582 | 570 |
| 583 #undef RETURN_NATIVE_CALL | 571 #undef RETURN_NATIVE_CALL |
| 584 | 572 |
| 585 | 573 |
| 586 MaybeHandle<Object> Execution::ToInt32(Isolate* isolate, Handle<Object> obj) { | 574 MaybeHandle<Object> Execution::ToInt32(Isolate* isolate, Handle<Object> obj) { |
| 587 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Execution::ToNumber(isolate, obj), | 575 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Object::ToNumber(isolate, obj), |
| 588 Object); | 576 Object); |
| 589 return isolate->factory()->NewNumberFromInt(DoubleToInt32(obj->Number())); | 577 return isolate->factory()->NewNumberFromInt(DoubleToInt32(obj->Number())); |
| 590 } | 578 } |
| 591 | 579 |
| 592 | 580 |
| 593 MaybeHandle<Object> Execution::ToObject(Isolate* isolate, Handle<Object> obj) { | 581 MaybeHandle<Object> Execution::ToObject(Isolate* isolate, Handle<Object> obj) { |
| 594 Handle<JSReceiver> receiver; | 582 Handle<JSReceiver> receiver; |
| 595 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { | 583 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { |
| 596 return receiver; | 584 return receiver; |
| 597 } | 585 } |
| 598 THROW_NEW_ERROR( | 586 THROW_NEW_ERROR( |
| 599 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject), Object); | 587 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject), Object); |
| 600 } | 588 } |
| 601 | 589 |
| 602 | 590 |
| 603 MaybeHandle<Object> Execution::ToUint32(Isolate* isolate, Handle<Object> obj) { | 591 MaybeHandle<Object> Execution::ToUint32(Isolate* isolate, Handle<Object> obj) { |
| 604 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Execution::ToNumber(isolate, obj), | 592 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Object::ToNumber(isolate, obj), |
| 605 Object); | 593 Object); |
| 606 return isolate->factory()->NewNumberFromUint(DoubleToUint32(obj->Number())); | 594 return isolate->factory()->NewNumberFromUint(DoubleToUint32(obj->Number())); |
| 607 } | 595 } |
| 608 | 596 |
| 609 | 597 |
| 610 MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, | 598 MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, |
| 611 Handle<String> flags) { | 599 Handle<String> flags) { |
| 612 Isolate* isolate = pattern->GetIsolate(); | 600 Isolate* isolate = pattern->GetIsolate(); |
| 613 Handle<JSFunction> function = Handle<JSFunction>( | 601 Handle<JSFunction> function = Handle<JSFunction>( |
| 614 isolate->native_context()->regexp_function()); | 602 isolate->native_context()->regexp_function()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 663 |
| 676 isolate_->counters()->stack_interrupts()->Increment(); | 664 isolate_->counters()->stack_interrupts()->Increment(); |
| 677 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 665 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 678 isolate_->runtime_profiler()->OptimizeNow(); | 666 isolate_->runtime_profiler()->OptimizeNow(); |
| 679 | 667 |
| 680 return isolate_->heap()->undefined_value(); | 668 return isolate_->heap()->undefined_value(); |
| 681 } | 669 } |
| 682 | 670 |
| 683 } // namespace internal | 671 } // namespace internal |
| 684 } // namespace v8 | 672 } // namespace v8 |
| OLD | NEW |