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

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

Issue 177683002: Mode clean-up pt 1: rename classic/non-strict mode to sloppy mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 } 1733 }
1734 } 1734 }
1735 1735
1736 1736
1737 MaybeObject* JSObject::ResetElements() { 1737 MaybeObject* JSObject::ResetElements() {
1738 if (map()->is_observed()) { 1738 if (map()->is_observed()) {
1739 // Maintain invariant that observed elements are always in dictionary mode. 1739 // Maintain invariant that observed elements are always in dictionary mode.
1740 SeededNumberDictionary* dictionary; 1740 SeededNumberDictionary* dictionary;
1741 MaybeObject* maybe = SeededNumberDictionary::Allocate(GetHeap(), 0); 1741 MaybeObject* maybe = SeededNumberDictionary::Allocate(GetHeap(), 0);
1742 if (!maybe->To(&dictionary)) return maybe; 1742 if (!maybe->To(&dictionary)) return maybe;
1743 if (map() == GetHeap()->non_strict_arguments_elements_map()) { 1743 if (map() == GetHeap()->sloppy_arguments_elements_map()) {
1744 FixedArray::cast(elements())->set(1, dictionary); 1744 FixedArray::cast(elements())->set(1, dictionary);
1745 } else { 1745 } else {
1746 set_elements(dictionary); 1746 set_elements(dictionary);
1747 } 1747 }
1748 return this; 1748 return this;
1749 } 1749 }
1750 1750
1751 ElementsKind elements_kind = GetInitialFastElementsKind(); 1751 ElementsKind elements_kind = GetInitialFastElementsKind();
1752 if (!FLAG_smi_only_arrays) { 1752 if (!FLAG_smi_only_arrays) {
1753 elements_kind = FastSmiToObjectElementsKind(elements_kind); 1753 elements_kind = FastSmiToObjectElementsKind(elements_kind);
(...skipping 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after
5132 } 5132 }
5133 5133
5134 5134
5135 LanguageMode SharedFunctionInfo::language_mode() { 5135 LanguageMode SharedFunctionInfo::language_mode() {
5136 int hints = compiler_hints(); 5136 int hints = compiler_hints();
5137 if (BooleanBit::get(hints, kExtendedModeFunction)) { 5137 if (BooleanBit::get(hints, kExtendedModeFunction)) {
5138 ASSERT(BooleanBit::get(hints, kStrictModeFunction)); 5138 ASSERT(BooleanBit::get(hints, kStrictModeFunction));
5139 return EXTENDED_MODE; 5139 return EXTENDED_MODE;
5140 } 5140 }
5141 return BooleanBit::get(hints, kStrictModeFunction) 5141 return BooleanBit::get(hints, kStrictModeFunction)
5142 ? STRICT_MODE : CLASSIC_MODE; 5142 ? STRICT_MODE : SLOPPY_MODE;
5143 } 5143 }
5144 5144
5145 5145
5146 void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) { 5146 void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
5147 // We only allow language mode transitions that go set the same language mode 5147 // We only allow language mode transitions that go set the same language mode
5148 // again or go up in the chain: 5148 // again or go up in the chain:
5149 // CLASSIC_MODE -> STRICT_MODE -> EXTENDED_MODE. 5149 // SLOPPY_MODE -> STRICT_MODE -> EXTENDED_MODE.
5150 ASSERT(this->language_mode() == CLASSIC_MODE || 5150 ASSERT(this->language_mode() == SLOPPY_MODE ||
5151 this->language_mode() == language_mode || 5151 this->language_mode() == language_mode ||
5152 language_mode == EXTENDED_MODE); 5152 language_mode == EXTENDED_MODE);
5153 int hints = compiler_hints(); 5153 int hints = compiler_hints();
5154 hints = BooleanBit::set( 5154 hints = BooleanBit::set(
5155 hints, kStrictModeFunction, language_mode != CLASSIC_MODE); 5155 hints, kStrictModeFunction, language_mode != SLOPPY_MODE);
5156 hints = BooleanBit::set( 5156 hints = BooleanBit::set(
5157 hints, kExtendedModeFunction, language_mode == EXTENDED_MODE); 5157 hints, kExtendedModeFunction, language_mode == EXTENDED_MODE);
5158 set_compiler_hints(hints); 5158 set_compiler_hints(hints);
5159 } 5159 }
5160 5160
5161 5161
5162 bool SharedFunctionInfo::is_classic_mode() { 5162 bool SharedFunctionInfo::is_sloppy_mode() {
5163 return !BooleanBit::get(compiler_hints(), kStrictModeFunction); 5163 return !BooleanBit::get(compiler_hints(), kStrictModeFunction);
5164 } 5164 }
5165 5165
5166 BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode, 5166 BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode,
5167 kExtendedModeFunction) 5167 kExtendedModeFunction)
5168 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) 5168 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
5169 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin, 5169 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin,
5170 kInlineBuiltin) 5170 kInlineBuiltin)
5171 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, 5171 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
5172 name_should_print_as_anonymous, 5172 name_should_print_as_anonymous,
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
5909 ASSERT((IsFastSmiOrObjectElementsKind(kind) && 5909 ASSERT((IsFastSmiOrObjectElementsKind(kind) &&
5910 (map == GetHeap()->fixed_array_map() || 5910 (map == GetHeap()->fixed_array_map() ||
5911 map == GetHeap()->fixed_cow_array_map())) || 5911 map == GetHeap()->fixed_cow_array_map())) ||
5912 (IsFastDoubleElementsKind(kind) && 5912 (IsFastDoubleElementsKind(kind) &&
5913 (fixed_array->IsFixedDoubleArray() || 5913 (fixed_array->IsFixedDoubleArray() ||
5914 fixed_array == GetHeap()->empty_fixed_array())) || 5914 fixed_array == GetHeap()->empty_fixed_array())) ||
5915 (kind == DICTIONARY_ELEMENTS && 5915 (kind == DICTIONARY_ELEMENTS &&
5916 fixed_array->IsFixedArray() && 5916 fixed_array->IsFixedArray() &&
5917 fixed_array->IsDictionary()) || 5917 fixed_array->IsDictionary()) ||
5918 (kind > DICTIONARY_ELEMENTS)); 5918 (kind > DICTIONARY_ELEMENTS));
5919 ASSERT((kind != NON_STRICT_ARGUMENTS_ELEMENTS) || 5919 ASSERT((kind != SLOPPY_ARGUMENTS_ELEMENTS) ||
5920 (elements()->IsFixedArray() && elements()->length() >= 2)); 5920 (elements()->IsFixedArray() && elements()->length() >= 2));
5921 } 5921 }
5922 #endif 5922 #endif
5923 return kind; 5923 return kind;
5924 } 5924 }
5925 5925
5926 5926
5927 ElementsAccessor* JSObject::GetElementsAccessor() { 5927 ElementsAccessor* JSObject::GetElementsAccessor() {
5928 return ElementsAccessor::ForKind(GetElementsKind()); 5928 return ElementsAccessor::ForKind(GetElementsKind());
5929 } 5929 }
(...skipping 27 matching lines...) Expand all
5957 bool JSObject::HasFastElements() { 5957 bool JSObject::HasFastElements() {
5958 return IsFastElementsKind(GetElementsKind()); 5958 return IsFastElementsKind(GetElementsKind());
5959 } 5959 }
5960 5960
5961 5961
5962 bool JSObject::HasDictionaryElements() { 5962 bool JSObject::HasDictionaryElements() {
5963 return GetElementsKind() == DICTIONARY_ELEMENTS; 5963 return GetElementsKind() == DICTIONARY_ELEMENTS;
5964 } 5964 }
5965 5965
5966 5966
5967 bool JSObject::HasNonStrictArgumentsElements() { 5967 bool JSObject::HasSloppyArgumentsElements() {
5968 return GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS; 5968 return GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS;
5969 } 5969 }
5970 5970
5971 5971
5972 bool JSObject::HasExternalArrayElements() { 5972 bool JSObject::HasExternalArrayElements() {
5973 HeapObject* array = elements(); 5973 HeapObject* array = elements();
5974 ASSERT(array != NULL); 5974 ASSERT(array != NULL);
5975 return array->IsExternalArray(); 5975 return array->IsExternalArray();
5976 } 5976 }
5977 5977
5978 5978
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
6760 #undef READ_UINT32_FIELD 6760 #undef READ_UINT32_FIELD
6761 #undef WRITE_UINT32_FIELD 6761 #undef WRITE_UINT32_FIELD
6762 #undef READ_SHORT_FIELD 6762 #undef READ_SHORT_FIELD
6763 #undef WRITE_SHORT_FIELD 6763 #undef WRITE_SHORT_FIELD
6764 #undef READ_BYTE_FIELD 6764 #undef READ_BYTE_FIELD
6765 #undef WRITE_BYTE_FIELD 6765 #undef WRITE_BYTE_FIELD
6766 6766
6767 } } // namespace v8::internal 6767 } } // namespace v8::internal
6768 6768
6769 #endif // V8_OBJECTS_INL_H_ 6769 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698