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

Side by Side Diff: src/objects-inl.h

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase again. 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/objects-debug.cc ('k') | src/objects-printer.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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return Object::IsHeapObject() && 180 return Object::IsHeapObject() &&
181 HeapObject::cast(this)->map()->instance_type() <= LAST_NAME_TYPE; 181 HeapObject::cast(this)->map()->instance_type() <= LAST_NAME_TYPE;
182 } 182 }
183 183
184 184
185 bool Object::IsUniqueName() const { 185 bool Object::IsUniqueName() const {
186 return IsInternalizedString() || IsSymbol(); 186 return IsInternalizedString() || IsSymbol();
187 } 187 }
188 188
189 189
190 bool Object::IsCallable() const {
191 return Object::IsHeapObject() && HeapObject::cast(this)->map()->is_callable();
192 }
193
194
190 bool Object::IsSpecObject() const { 195 bool Object::IsSpecObject() const {
191 return Object::IsHeapObject() 196 return Object::IsHeapObject()
192 && HeapObject::cast(this)->map()->instance_type() >= FIRST_SPEC_OBJECT_TYPE; 197 && HeapObject::cast(this)->map()->instance_type() >= FIRST_SPEC_OBJECT_TYPE;
193 } 198 }
194 199
195 200
201 // TODO(rossberg): Remove this and use the spec compliant IsCallable instead.
196 bool Object::IsSpecFunction() const { 202 bool Object::IsSpecFunction() const {
197 if (!Object::IsHeapObject()) return false; 203 if (!Object::IsHeapObject()) return false;
198 InstanceType type = HeapObject::cast(this)->map()->instance_type(); 204 InstanceType type = HeapObject::cast(this)->map()->instance_type();
199 return type == JS_FUNCTION_TYPE || type == JS_FUNCTION_PROXY_TYPE; 205 return type == JS_FUNCTION_TYPE || type == JS_FUNCTION_PROXY_TYPE;
200 } 206 }
201 207
202 208
203 bool Object::IsTemplateInfo() const { 209 bool Object::IsTemplateInfo() const {
204 return IsObjectTemplateInfo() || IsFunctionTemplateInfo(); 210 return IsObjectTemplateInfo() || IsFunctionTemplateInfo();
205 } 211 }
(...skipping 4311 matching lines...) Expand 10 before | Expand all | Expand 10 after
4517 set_bit_field(FunctionWithPrototype::update(bit_field(), value)); 4523 set_bit_field(FunctionWithPrototype::update(bit_field(), value));
4518 } 4524 }
4519 4525
4520 4526
4521 bool Map::function_with_prototype() { 4527 bool Map::function_with_prototype() {
4522 return FunctionWithPrototype::decode(bit_field()); 4528 return FunctionWithPrototype::decode(bit_field());
4523 } 4529 }
4524 4530
4525 4531
4526 void Map::set_is_hidden_prototype() { 4532 void Map::set_is_hidden_prototype() {
4527 set_bit_field(bit_field() | (1 << kIsHiddenPrototype)); 4533 set_bit_field3(IsHiddenPrototype::update(bit_field3(), true));
4528 } 4534 }
4529 4535
4530 4536
4531 bool Map::is_hidden_prototype() { 4537 bool Map::is_hidden_prototype() const {
4532 return ((1 << kIsHiddenPrototype) & bit_field()) != 0; 4538 return IsHiddenPrototype::decode(bit_field3());
4533 } 4539 }
4534 4540
4535 4541
4536 void Map::set_has_indexed_interceptor() { 4542 void Map::set_has_indexed_interceptor() {
4537 set_bit_field(bit_field() | (1 << kHasIndexedInterceptor)); 4543 set_bit_field(bit_field() | (1 << kHasIndexedInterceptor));
4538 } 4544 }
4539 4545
4540 4546
4541 bool Map::has_indexed_interceptor() { 4547 bool Map::has_indexed_interceptor() {
4542 return ((1 << kHasIndexedInterceptor) & bit_field()) != 0; 4548 return ((1 << kHasIndexedInterceptor) & bit_field()) != 0;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4668 void Map::set_owns_descriptors(bool owns_descriptors) { 4674 void Map::set_owns_descriptors(bool owns_descriptors) {
4669 set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors)); 4675 set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors));
4670 } 4676 }
4671 4677
4672 4678
4673 bool Map::owns_descriptors() { 4679 bool Map::owns_descriptors() {
4674 return OwnsDescriptors::decode(bit_field3()); 4680 return OwnsDescriptors::decode(bit_field3());
4675 } 4681 }
4676 4682
4677 4683
4678 void Map::set_has_instance_call_handler() { 4684 void Map::set_is_callable() { set_bit_field(bit_field() | (1 << kIsCallable)); }
4679 set_bit_field3(HasInstanceCallHandler::update(bit_field3(), true)); 4685
4686
4687 bool Map::is_callable() const {
4688 return ((1 << kIsCallable) & bit_field()) != 0;
4680 } 4689 }
4681 4690
4682 4691
4683 bool Map::has_instance_call_handler() {
4684 return HasInstanceCallHandler::decode(bit_field3());
4685 }
4686
4687
4688 void Map::deprecate() { 4692 void Map::deprecate() {
4689 set_bit_field3(Deprecated::update(bit_field3(), true)); 4693 set_bit_field3(Deprecated::update(bit_field3(), true));
4690 } 4694 }
4691 4695
4692 4696
4693 bool Map::is_deprecated() { 4697 bool Map::is_deprecated() {
4694 return Deprecated::decode(bit_field3()); 4698 return Deprecated::decode(bit_field3());
4695 } 4699 }
4696 4700
4697 4701
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
6286 6290
6287 6291
6288 int JSFunction::NumberOfLiterals() { 6292 int JSFunction::NumberOfLiterals() {
6289 DCHECK(!shared()->bound()); 6293 DCHECK(!shared()->bound());
6290 return literals()->length(); 6294 return literals()->length();
6291 } 6295 }
6292 6296
6293 6297
6294 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) 6298 ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
6295 ACCESSORS(JSProxy, hash, Object, kHashOffset) 6299 ACCESSORS(JSProxy, hash, Object, kHashOffset)
6296 ACCESSORS(JSFunctionProxy, call_trap, Object, kCallTrapOffset) 6300 ACCESSORS(JSFunctionProxy, call_trap, JSReceiver, kCallTrapOffset)
6297 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset) 6301 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset)
6298 6302
6299 6303
6300 void JSProxy::InitializeBody(int object_size, Object* value) { 6304 void JSProxy::InitializeBody(int object_size, Object* value) {
6301 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); 6305 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value));
6302 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { 6306 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
6303 WRITE_FIELD(this, offset, value); 6307 WRITE_FIELD(this, offset, value);
6304 } 6308 }
6305 } 6309 }
6306 6310
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
7887 #undef READ_INT64_FIELD 7891 #undef READ_INT64_FIELD
7888 #undef WRITE_INT64_FIELD 7892 #undef WRITE_INT64_FIELD
7889 #undef READ_BYTE_FIELD 7893 #undef READ_BYTE_FIELD
7890 #undef WRITE_BYTE_FIELD 7894 #undef WRITE_BYTE_FIELD
7891 #undef NOBARRIER_READ_BYTE_FIELD 7895 #undef NOBARRIER_READ_BYTE_FIELD
7892 #undef NOBARRIER_WRITE_BYTE_FIELD 7896 #undef NOBARRIER_WRITE_BYTE_FIELD
7893 7897
7894 } } // namespace v8::internal 7898 } } // namespace v8::internal
7895 7899
7896 #endif // V8_OBJECTS_INL_H_ 7900 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698