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

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

Issue 1358423002: [es6] Introduce spec compliant IsConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix stupid fuzzer failure (constructor bit set on sloppy/strict arguments). Fix MIPS/MIPS64 typos, … Created 5 years, 2 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 190 bool Object::IsCallable() const {
191 return Object::IsHeapObject() && HeapObject::cast(this)->map()->is_callable(); 191 return Object::IsHeapObject() && HeapObject::cast(this)->map()->is_callable();
192 } 192 }
193 193
194 194
195 bool Object::IsConstructor() const {
196 return Object::IsHeapObject() &&
197 HeapObject::cast(this)->map()->is_constructor();
198 }
199
200
195 bool Object::IsSpecObject() const { 201 bool Object::IsSpecObject() const {
196 return Object::IsHeapObject() 202 return Object::IsHeapObject()
197 && HeapObject::cast(this)->map()->instance_type() >= FIRST_SPEC_OBJECT_TYPE; 203 && HeapObject::cast(this)->map()->instance_type() >= FIRST_SPEC_OBJECT_TYPE;
198 } 204 }
199 205
200 206
201 bool Object::IsTemplateInfo() const { 207 bool Object::IsTemplateInfo() const {
202 return IsObjectTemplateInfo() || IsFunctionTemplateInfo(); 208 return IsObjectTemplateInfo() || IsFunctionTemplateInfo();
203 } 209 }
204 210
(...skipping 4320 matching lines...) Expand 10 before | Expand all | Expand 10 after
4525 set_bit_field(bit_field() & ~(1 << kHasNonInstancePrototype)); 4531 set_bit_field(bit_field() & ~(1 << kHasNonInstancePrototype));
4526 } 4532 }
4527 } 4533 }
4528 4534
4529 4535
4530 bool Map::has_non_instance_prototype() { 4536 bool Map::has_non_instance_prototype() {
4531 return ((1 << kHasNonInstancePrototype) & bit_field()) != 0; 4537 return ((1 << kHasNonInstancePrototype) & bit_field()) != 0;
4532 } 4538 }
4533 4539
4534 4540
4535 void Map::set_function_with_prototype(bool value) { 4541 void Map::set_is_constructor(bool value) {
4536 set_bit_field(FunctionWithPrototype::update(bit_field(), value)); 4542 if (value) {
4543 set_bit_field(bit_field() | (1 << kIsConstructor));
4544 } else {
4545 set_bit_field(bit_field() & ~(1 << kIsConstructor));
4546 }
4537 } 4547 }
4538 4548
4539 4549
4540 bool Map::function_with_prototype() { 4550 bool Map::is_constructor() const {
4541 return FunctionWithPrototype::decode(bit_field()); 4551 return ((1 << kIsConstructor) & bit_field()) != 0;
4542 } 4552 }
4543 4553
4544 4554
4545 void Map::set_is_hidden_prototype() { 4555 void Map::set_is_hidden_prototype() {
4546 set_bit_field3(IsHiddenPrototype::update(bit_field3(), true)); 4556 set_bit_field3(IsHiddenPrototype::update(bit_field3(), true));
4547 } 4557 }
4548 4558
4549 4559
4550 bool Map::is_hidden_prototype() const { 4560 bool Map::is_hidden_prototype() const {
4551 return IsHiddenPrototype::decode(bit_field3()); 4561 return IsHiddenPrototype::decode(bit_field3());
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4788 4798
4789 bool Map::IsPrimitiveMap() { 4799 bool Map::IsPrimitiveMap() {
4790 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); 4800 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE);
4791 return instance_type() <= LAST_PRIMITIVE_TYPE; 4801 return instance_type() <= LAST_PRIMITIVE_TYPE;
4792 } 4802 }
4793 bool Map::IsJSObjectMap() { 4803 bool Map::IsJSObjectMap() {
4794 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE); 4804 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
4795 return instance_type() >= FIRST_JS_OBJECT_TYPE; 4805 return instance_type() >= FIRST_JS_OBJECT_TYPE;
4796 } 4806 }
4797 bool Map::IsJSArrayMap() { return instance_type() == JS_ARRAY_TYPE; } 4807 bool Map::IsJSArrayMap() { return instance_type() == JS_ARRAY_TYPE; }
4808 bool Map::IsJSFunctionMap() { return instance_type() == JS_FUNCTION_TYPE; }
4798 bool Map::IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; } 4809 bool Map::IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; }
4799 bool Map::IsJSProxyMap() { 4810 bool Map::IsJSProxyMap() {
4800 InstanceType type = instance_type(); 4811 InstanceType type = instance_type();
4801 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; 4812 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE;
4802 } 4813 }
4803 bool Map::IsJSGlobalProxyMap() { 4814 bool Map::IsJSGlobalProxyMap() {
4804 return instance_type() == JS_GLOBAL_PROXY_TYPE; 4815 return instance_type() == JS_GLOBAL_PROXY_TYPE;
4805 } 4816 }
4806 bool Map::IsJSGlobalObjectMap() { 4817 bool Map::IsJSGlobalObjectMap() {
4807 return instance_type() == JS_GLOBAL_OBJECT_TYPE; 4818 return instance_type() == JS_GLOBAL_OBJECT_TYPE;
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
6249 if (map()->has_non_instance_prototype()) { 6260 if (map()->has_non_instance_prototype()) {
6250 Object* prototype = map()->GetConstructor(); 6261 Object* prototype = map()->GetConstructor();
6251 // The map must have a prototype in that field, not a back pointer. 6262 // The map must have a prototype in that field, not a back pointer.
6252 DCHECK(!prototype->IsMap()); 6263 DCHECK(!prototype->IsMap());
6253 return prototype; 6264 return prototype;
6254 } 6265 }
6255 return instance_prototype(); 6266 return instance_prototype();
6256 } 6267 }
6257 6268
6258 6269
6259 bool JSFunction::should_have_prototype() {
6260 return map()->function_with_prototype();
6261 }
6262
6263
6264 bool JSFunction::is_compiled() { 6270 bool JSFunction::is_compiled() {
6265 Builtins* builtins = GetIsolate()->builtins(); 6271 Builtins* builtins = GetIsolate()->builtins();
6266 return code() != builtins->builtin(Builtins::kCompileLazy) && 6272 return code() != builtins->builtin(Builtins::kCompileLazy) &&
6267 code() != builtins->builtin(Builtins::kCompileOptimized) && 6273 code() != builtins->builtin(Builtins::kCompileOptimized) &&
6268 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); 6274 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent);
6269 } 6275 }
6270 6276
6271 6277
6272 bool JSFunction::has_simple_parameters() { 6278 bool JSFunction::has_simple_parameters() {
6273 return shared()->has_simple_parameters(); 6279 return shared()->has_simple_parameters();
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
8007 #undef READ_INT64_FIELD 8013 #undef READ_INT64_FIELD
8008 #undef WRITE_INT64_FIELD 8014 #undef WRITE_INT64_FIELD
8009 #undef READ_BYTE_FIELD 8015 #undef READ_BYTE_FIELD
8010 #undef WRITE_BYTE_FIELD 8016 #undef WRITE_BYTE_FIELD
8011 #undef NOBARRIER_READ_BYTE_FIELD 8017 #undef NOBARRIER_READ_BYTE_FIELD
8012 #undef NOBARRIER_WRITE_BYTE_FIELD 8018 #undef NOBARRIER_WRITE_BYTE_FIELD
8013 8019
8014 } } // namespace v8::internal 8020 } } // namespace v8::internal
8015 8021
8016 #endif // V8_OBJECTS_INL_H_ 8022 #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