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

Unified Diff: src/objects-inl.h

Issue 1745013002: [runtime] inline fast-path ToName (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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.cc ('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 86cd2d2a7c57f5c5c1fa65cb2bd0604804f89547..3619b498455732a94c5e81301df66ab423d7c658 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1003,6 +1003,24 @@ bool Object::FitsRepresentation(Representation representation) {
return true;
}
+bool Object::ToUint32(uint32_t* value) {
+ if (IsSmi()) {
+ int num = Smi::cast(this)->value();
+ if (num < 0) return false;
+ *value = static_cast<uint32_t>(num);
+ return true;
+ }
+ if (IsHeapNumber()) {
+ double num = HeapNumber::cast(this)->value();
+ if (num < 0) return false;
+ uint32_t uint_value = FastD2UI(num);
+ if (FastUI2D(uint_value) == num) {
+ *value = uint_value;
+ return true;
+ }
+ }
+ return false;
+}
// static
MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
@@ -1013,6 +1031,12 @@ MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
// static
+MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
+ if (input->IsName()) return Handle<Name>::cast(input);
+ return ConvertToName(isolate, input);
+}
+
+// static
MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input,
ToPrimitiveHint hint) {
if (input->IsPrimitive()) return input;
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698