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

Side by Side Diff: src/objects.h

Issue 1324713002: [es6] Implement Date.prototype[@@toPrimitive] as C++ builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Michi's comments. Created 5 years, 3 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
« no previous file with comments | « src/date.js ('k') | src/objects.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 // 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 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS, 166 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS,
167 STORE_NO_TRANSITION_HANDLE_COW 167 STORE_NO_TRANSITION_HANDLE_COW
168 }; 168 };
169 169
170 170
171 // Valid hints for the abstract operation ToPrimitive, 171 // Valid hints for the abstract operation ToPrimitive,
172 // implemented according to ES6, section 7.1.1. 172 // implemented according to ES6, section 7.1.1.
173 enum class ToPrimitiveHint { kDefault, kNumber, kString }; 173 enum class ToPrimitiveHint { kDefault, kNumber, kString };
174 174
175 175
176 // Valid hints for the abstract operation OrdinaryToPrimitive,
177 // implemented according to ES6, section 7.1.1.
178 enum class OrdinaryToPrimitiveHint { kNumber, kString };
179
180
176 enum TypeofMode { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; 181 enum TypeofMode { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
177 182
178 183
179 enum MutableMode { 184 enum MutableMode {
180 MUTABLE, 185 MUTABLE,
181 IMMUTABLE 186 IMMUTABLE
182 }; 187 };
183 188
184 189
185 enum ExternalArrayType { 190 enum ExternalArrayType {
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 // JSObject and JSProxy. 1677 // JSObject and JSProxy.
1673 class JSReceiver: public HeapObject { 1678 class JSReceiver: public HeapObject {
1674 public: 1679 public:
1675 DECLARE_CAST(JSReceiver) 1680 DECLARE_CAST(JSReceiver)
1676 1681
1677 // ES6 section 7.1.1 ToPrimitive 1682 // ES6 section 7.1.1 ToPrimitive
1678 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( 1683 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive(
1679 Handle<JSReceiver> receiver, 1684 Handle<JSReceiver> receiver,
1680 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); 1685 ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
1681 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryToPrimitive( 1686 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryToPrimitive(
1682 Handle<JSReceiver> receiver, Handle<String> hint); 1687 Handle<JSReceiver> receiver, OrdinaryToPrimitiveHint hint);
1683 1688
1684 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. 1689 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
1685 MUST_USE_RESULT static inline Maybe<bool> HasProperty( 1690 MUST_USE_RESULT static inline Maybe<bool> HasProperty(
1686 Handle<JSReceiver> object, Handle<Name> name); 1691 Handle<JSReceiver> object, Handle<Name> name);
1687 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>, 1692 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>,
1688 Handle<Name> name); 1693 Handle<Name> name);
1689 MUST_USE_RESULT static inline Maybe<bool> HasElement( 1694 MUST_USE_RESULT static inline Maybe<bool> HasElement(
1690 Handle<JSReceiver> object, uint32_t index); 1695 Handle<JSReceiver> object, uint32_t index);
1691 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement( 1696 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement(
1692 Handle<JSReceiver> object, uint32_t index); 1697 Handle<JSReceiver> object, uint32_t index);
(...skipping 5565 matching lines...) Expand 10 before | Expand all | Expand 10 after
7258 DECL_ACCESSORS(cache_stamp, Object) 7263 DECL_ACCESSORS(cache_stamp, Object)
7259 7264
7260 DECLARE_CAST(JSDate) 7265 DECLARE_CAST(JSDate)
7261 7266
7262 // Returns the date field with the specified index. 7267 // Returns the date field with the specified index.
7263 // See FieldIndex for the list of date fields. 7268 // See FieldIndex for the list of date fields.
7264 static Object* GetField(Object* date, Smi* index); 7269 static Object* GetField(Object* date, Smi* index);
7265 7270
7266 void SetValue(Object* value, bool is_value_nan); 7271 void SetValue(Object* value, bool is_value_nan);
7267 7272
7273 // ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ]
7274 static MUST_USE_RESULT MaybeHandle<Object> ToPrimitive(
7275 Handle<JSReceiver> receiver, Handle<Object> hint);
7268 7276
7269 // Dispatched behavior. 7277 // Dispatched behavior.
7270 DECLARE_PRINTER(JSDate) 7278 DECLARE_PRINTER(JSDate)
7271 DECLARE_VERIFIER(JSDate) 7279 DECLARE_VERIFIER(JSDate)
7272 7280
7273 // The order is important. It must be kept in sync with date macros 7281 // The order is important. It must be kept in sync with date macros
7274 // in macros.py. 7282 // in macros.py.
7275 enum FieldIndex { 7283 enum FieldIndex {
7276 kDateValue, 7284 kDateValue,
7277 kYear, 7285 kYear,
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
8108 inline bool AsArrayIndex(uint32_t* index); 8116 inline bool AsArrayIndex(uint32_t* index);
8109 8117
8110 // If the name is private, it can only name own properties. 8118 // If the name is private, it can only name own properties.
8111 inline bool IsPrivate(); 8119 inline bool IsPrivate();
8112 8120
8113 // If the name is a non-flat string, this method returns a flat version of the 8121 // If the name is a non-flat string, this method returns a flat version of the
8114 // string. Otherwise it'll just return the input. 8122 // string. Otherwise it'll just return the input.
8115 static inline Handle<Name> Flatten(Handle<Name> name, 8123 static inline Handle<Name> Flatten(Handle<Name> name,
8116 PretenureFlag pretenure = NOT_TENURED); 8124 PretenureFlag pretenure = NOT_TENURED);
8117 8125
8126 // Return a string version of this name that is converted according to the
8127 // rules described in ES6 section 9.2.11.
8128 MUST_USE_RESULT static MaybeHandle<String> ToFunctionName(Handle<Name> name);
8129
8118 DECLARE_CAST(Name) 8130 DECLARE_CAST(Name)
8119 8131
8120 DECLARE_PRINTER(Name) 8132 DECLARE_PRINTER(Name)
8121 #if TRACE_MAPS 8133 #if TRACE_MAPS
8122 void NameShortPrint(); 8134 void NameShortPrint();
8123 int NameShortPrint(Vector<char> str); 8135 int NameShortPrint(Vector<char> str);
8124 #endif 8136 #endif
8125 8137
8126 // Layout description. 8138 // Layout description.
8127 static const int kHashFieldSlot = HeapObject::kHeaderSize; 8139 static const int kHashFieldSlot = HeapObject::kHeaderSize;
(...skipping 2242 matching lines...) Expand 10 before | Expand all | Expand 10 after
10370 } else { 10382 } else {
10371 value &= ~(1 << bit_position); 10383 value &= ~(1 << bit_position);
10372 } 10384 }
10373 return value; 10385 return value;
10374 } 10386 }
10375 }; 10387 };
10376 10388
10377 } } // namespace v8::internal 10389 } } // namespace v8::internal
10378 10390
10379 #endif // V8_OBJECTS_H_ 10391 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/date.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698