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

Unified Diff: src/objects-inl.h

Issue 204603003: ElementsAccessor::SetLength() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 618cf30f760affb5a163268e60f2410e54d275bd..83f11e7f16618a52699c857efd176e0b0c8959bd 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1031,6 +1031,21 @@ bool Object::IsNaN() {
}
+// static
+Handle<Object> Object::ToSmi(Isolate* isolate, Handle<Object> object) {
+ if (object->IsSmi()) return object;
+ if (object->IsHeapNumber()) {
+ double value = Handle<HeapNumber>::cast(object)->value();
+ int int_value = FastD2I(value);
+ if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
+ return handle(Smi::FromInt(int_value), isolate);
+ }
+ }
+ return Handle<Object>();
+}
+
+
+// TODO(ishell): Use handlified version instead.
MaybeObject* Object::ToSmi() {
if (IsSmi()) return this;
if (IsHeapNumber()) {
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698