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

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: 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
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 4269 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 set_bit_field(FunctionWithPrototype::update(bit_field(), value)); 4481 set_bit_field(FunctionWithPrototype::update(bit_field(), value));
4476 } 4482 }
4477 4483
4478 4484
4479 bool Map::function_with_prototype() { 4485 bool Map::function_with_prototype() {
4480 return FunctionWithPrototype::decode(bit_field()); 4486 return FunctionWithPrototype::decode(bit_field());
4481 } 4487 }
4482 4488
4483 4489
4484 void Map::set_is_hidden_prototype() { 4490 void Map::set_is_hidden_prototype() {
4485 set_bit_field(bit_field() | (1 << kIsHiddenPrototype)); 4491 set_bit_field3(IsHiddenPrototype::update(bit_field3(), true));
4486 } 4492 }
4487 4493
4488 4494
4489 bool Map::is_hidden_prototype() { 4495 bool Map::is_hidden_prototype() const {
4490 return ((1 << kIsHiddenPrototype) & bit_field()) != 0; 4496 return IsHiddenPrototype::decode(bit_field3());
4491 } 4497 }
4492 4498
4493 4499
4494 void Map::set_has_indexed_interceptor() { 4500 void Map::set_has_indexed_interceptor() {
4495 set_bit_field(bit_field() | (1 << kHasIndexedInterceptor)); 4501 set_bit_field(bit_field() | (1 << kHasIndexedInterceptor));
4496 } 4502 }
4497 4503
4498 4504
4499 bool Map::has_indexed_interceptor() { 4505 bool Map::has_indexed_interceptor() {
4500 return ((1 << kHasIndexedInterceptor) & bit_field()) != 0; 4506 return ((1 << kHasIndexedInterceptor) & bit_field()) != 0;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4626 void Map::set_owns_descriptors(bool owns_descriptors) { 4632 void Map::set_owns_descriptors(bool owns_descriptors) {
4627 set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors)); 4633 set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors));
4628 } 4634 }
4629 4635
4630 4636
4631 bool Map::owns_descriptors() { 4637 bool Map::owns_descriptors() {
4632 return OwnsDescriptors::decode(bit_field3()); 4638 return OwnsDescriptors::decode(bit_field3());
4633 } 4639 }
4634 4640
4635 4641
4636 void Map::set_has_instance_call_handler() { 4642 void Map::set_is_callable() { set_bit_field(bit_field() | (1 << kIsCallable)); }
4637 set_bit_field3(HasInstanceCallHandler::update(bit_field3(), true)); 4643
4644
4645 bool Map::is_callable() const {
4646 return ((1 << kIsCallable) & bit_field()) != 0;
4638 } 4647 }
4639 4648
4640 4649
4641 bool Map::has_instance_call_handler() {
4642 return HasInstanceCallHandler::decode(bit_field3());
4643 }
4644
4645
4646 void Map::deprecate() { 4650 void Map::deprecate() {
4647 set_bit_field3(Deprecated::update(bit_field3(), true)); 4651 set_bit_field3(Deprecated::update(bit_field3(), true));
4648 } 4652 }
4649 4653
4650 4654
4651 bool Map::is_deprecated() { 4655 bool Map::is_deprecated() {
4652 return Deprecated::decode(bit_field3()); 4656 return Deprecated::decode(bit_field3());
4653 } 4657 }
4654 4658
4655 4659
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
6258 void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id, 6262 void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id,
6259 Object* value) { 6263 Object* value) {
6260 DCHECK(id < kJSBuiltinsCount); // id is unsigned. 6264 DCHECK(id < kJSBuiltinsCount); // id is unsigned.
6261 WRITE_FIELD(this, OffsetOfFunctionWithId(id), value); 6265 WRITE_FIELD(this, OffsetOfFunctionWithId(id), value);
6262 WRITE_BARRIER(GetHeap(), this, OffsetOfFunctionWithId(id), value); 6266 WRITE_BARRIER(GetHeap(), this, OffsetOfFunctionWithId(id), value);
6263 } 6267 }
6264 6268
6265 6269
6266 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) 6270 ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
6267 ACCESSORS(JSProxy, hash, Object, kHashOffset) 6271 ACCESSORS(JSProxy, hash, Object, kHashOffset)
6268 ACCESSORS(JSFunctionProxy, call_trap, Object, kCallTrapOffset) 6272 ACCESSORS(JSFunctionProxy, call_trap, JSReceiver, kCallTrapOffset)
6269 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset) 6273 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset)
6270 6274
6271 6275
6272 void JSProxy::InitializeBody(int object_size, Object* value) { 6276 void JSProxy::InitializeBody(int object_size, Object* value) {
6273 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); 6277 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value));
6274 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { 6278 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
6275 WRITE_FIELD(this, offset, value); 6279 WRITE_FIELD(this, offset, value);
6276 } 6280 }
6277 } 6281 }
6278 6282
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
7858 #undef READ_INT64_FIELD 7862 #undef READ_INT64_FIELD
7859 #undef WRITE_INT64_FIELD 7863 #undef WRITE_INT64_FIELD
7860 #undef READ_BYTE_FIELD 7864 #undef READ_BYTE_FIELD
7861 #undef WRITE_BYTE_FIELD 7865 #undef WRITE_BYTE_FIELD
7862 #undef NOBARRIER_READ_BYTE_FIELD 7866 #undef NOBARRIER_READ_BYTE_FIELD
7863 #undef NOBARRIER_WRITE_BYTE_FIELD 7867 #undef NOBARRIER_WRITE_BYTE_FIELD
7864 7868
7865 } } // namespace v8::internal 7869 } } // namespace v8::internal
7866 7870
7867 #endif // V8_OBJECTS_INL_H_ 7871 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698