| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 RETURN_NATIVE_CALL(to_detail_string, { obj }); | 547 RETURN_NATIVE_CALL(to_detail_string, { obj }); |
| 548 } | 548 } |
| 549 | 549 |
| 550 | 550 |
| 551 MaybeHandle<Object> Execution::ToInteger( | 551 MaybeHandle<Object> Execution::ToInteger( |
| 552 Isolate* isolate, Handle<Object> obj) { | 552 Isolate* isolate, Handle<Object> obj) { |
| 553 RETURN_NATIVE_CALL(to_integer, { obj }); | 553 RETURN_NATIVE_CALL(to_integer, { obj }); |
| 554 } | 554 } |
| 555 | 555 |
| 556 | 556 |
| 557 MaybeHandle<Object> Execution::ToUint32( | |
| 558 Isolate* isolate, Handle<Object> obj) { | |
| 559 RETURN_NATIVE_CALL(to_uint32, { obj }); | |
| 560 } | |
| 561 | |
| 562 | |
| 563 MaybeHandle<Object> Execution::ToInt32( | |
| 564 Isolate* isolate, Handle<Object> obj) { | |
| 565 RETURN_NATIVE_CALL(to_int32, { obj }); | |
| 566 } | |
| 567 | |
| 568 | |
| 569 MaybeHandle<Object> Execution::ToLength( | 557 MaybeHandle<Object> Execution::ToLength( |
| 570 Isolate* isolate, Handle<Object> obj) { | 558 Isolate* isolate, Handle<Object> obj) { |
| 571 RETURN_NATIVE_CALL(to_length, { obj }); | 559 RETURN_NATIVE_CALL(to_length, { obj }); |
| 572 } | 560 } |
| 573 | 561 |
| 574 | 562 |
| 575 MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) { | 563 MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) { |
| 576 Handle<Object> time_obj = isolate->factory()->NewNumber(time); | 564 Handle<Object> time_obj = isolate->factory()->NewNumber(time); |
| 577 RETURN_NATIVE_CALL(create_date, { time_obj }); | 565 RETURN_NATIVE_CALL(create_date, { time_obj }); |
| 578 } | 566 } |
| 579 | 567 |
| 580 | 568 |
| 581 #undef RETURN_NATIVE_CALL | 569 #undef RETURN_NATIVE_CALL |
| 582 | 570 |
| 583 | 571 |
| 572 MaybeHandle<Object> Execution::ToInt32(Isolate* isolate, Handle<Object> obj) { |
| 573 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Execution::ToNumber(isolate, obj), |
| 574 Object); |
| 575 return isolate->factory()->NewNumberFromInt(DoubleToInt32(obj->Number())); |
| 576 } |
| 577 |
| 578 |
| 584 MaybeHandle<Object> Execution::ToObject(Isolate* isolate, Handle<Object> obj) { | 579 MaybeHandle<Object> Execution::ToObject(Isolate* isolate, Handle<Object> obj) { |
| 585 Handle<JSReceiver> receiver; | 580 Handle<JSReceiver> receiver; |
| 586 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { | 581 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { |
| 587 return receiver; | 582 return receiver; |
| 588 } | 583 } |
| 589 THROW_NEW_ERROR( | 584 THROW_NEW_ERROR( |
| 590 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject), Object); | 585 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject), Object); |
| 591 } | 586 } |
| 592 | 587 |
| 593 | 588 |
| 589 MaybeHandle<Object> Execution::ToUint32(Isolate* isolate, Handle<Object> obj) { |
| 590 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Execution::ToNumber(isolate, obj), |
| 591 Object); |
| 592 return isolate->factory()->NewNumberFromUint(DoubleToUint32(obj->Number())); |
| 593 } |
| 594 |
| 595 |
| 594 MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, | 596 MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, |
| 595 Handle<String> flags) { | 597 Handle<String> flags) { |
| 596 Isolate* isolate = pattern->GetIsolate(); | 598 Isolate* isolate = pattern->GetIsolate(); |
| 597 Handle<JSFunction> function = Handle<JSFunction>( | 599 Handle<JSFunction> function = Handle<JSFunction>( |
| 598 isolate->native_context()->regexp_function()); | 600 isolate->native_context()->regexp_function()); |
| 599 Handle<Object> re_obj; | 601 Handle<Object> re_obj; |
| 600 ASSIGN_RETURN_ON_EXCEPTION( | 602 ASSIGN_RETURN_ON_EXCEPTION( |
| 601 isolate, re_obj, | 603 isolate, re_obj, |
| 602 RegExpImpl::CreateRegExpLiteral(function, pattern, flags), | 604 RegExpImpl::CreateRegExpLiteral(function, pattern, flags), |
| 603 JSRegExp); | 605 JSRegExp); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 663 |
| 662 isolate_->counters()->stack_interrupts()->Increment(); | 664 isolate_->counters()->stack_interrupts()->Increment(); |
| 663 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 665 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 664 isolate_->runtime_profiler()->OptimizeNow(); | 666 isolate_->runtime_profiler()->OptimizeNow(); |
| 665 | 667 |
| 666 return isolate_->heap()->undefined_value(); | 668 return isolate_->heap()->undefined_value(); |
| 667 } | 669 } |
| 668 | 670 |
| 669 } // namespace internal | 671 } // namespace internal |
| 670 } // namespace v8 | 672 } // namespace v8 |
| OLD | NEW |