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

Side by Side Diff: src/execution.cc

Issue 12459011: Avoid bool to Oddball conversions by being lazy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/execution.h ('k') | src/isolate.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 Isolate* isolate = Isolate::Current(); \ 594 Isolate* isolate = Isolate::Current(); \
595 Handle<Object> argv[] = args; \ 595 Handle<Object> argv[] = args; \
596 ASSERT(has_pending_exception != NULL); \ 596 ASSERT(has_pending_exception != NULL); \
597 return Call(isolate->name##_fun(), \ 597 return Call(isolate->name##_fun(), \
598 isolate->js_builtins_object(), \ 598 isolate->js_builtins_object(), \
599 ARRAY_SIZE(argv), argv, \ 599 ARRAY_SIZE(argv), argv, \
600 has_pending_exception); \ 600 has_pending_exception); \
601 } while (false) 601 } while (false)
602 602
603 603
604 Handle<Object> Execution::ToBoolean(Isolate* isolate, Handle<Object> obj) {
605 // See the similar code in runtime.js:ToBoolean.
606 if (obj->IsBoolean()) return obj;
607 bool result = true;
608 if (obj->IsString()) {
609 result = Handle<String>::cast(obj)->length() != 0;
610 } else if (obj->IsNull() || obj->IsUndefined()) {
611 result = false;
612 } else if (obj->IsNumber()) {
613 double value = obj->Number();
614 result = !((value == 0) || isnan(value));
615 }
616 return Handle<Object>(isolate->heap()->ToBoolean(result), isolate);
617 }
618
619
620 Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) { 604 Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) {
621 RETURN_NATIVE_CALL(to_number, { obj }, exc); 605 RETURN_NATIVE_CALL(to_number, { obj }, exc);
622 } 606 }
623 607
624 608
625 Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) { 609 Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) {
626 RETURN_NATIVE_CALL(to_string, { obj }, exc); 610 RETURN_NATIVE_CALL(to_string, { obj }, exc);
627 } 611 }
628 612
629 613
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 } 926 }
943 if (stack_guard->IsInterrupted()) { 927 if (stack_guard->IsInterrupted()) {
944 stack_guard->Continue(INTERRUPT); 928 stack_guard->Continue(INTERRUPT);
945 return isolate->StackOverflow(); 929 return isolate->StackOverflow();
946 } 930 }
947 return isolate->heap()->undefined_value(); 931 return isolate->heap()->undefined_value();
948 } 932 }
949 933
950 934
951 } } // namespace v8::internal 935 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698