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

Side by Side Diff: src/objects.cc

Issue 2381843002: Add Smi::Zero and replace all Smi::FromInt(0) calls (Closed)
Patch Set: Mark Smi::kZero as V8_EXPORT_PRIVATE Created 4 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.h ('k') | src/objects-debug.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 } 1192 }
1193 // Didn't find the required type in the inheritance chain. 1193 // Didn't find the required type in the inheritance chain.
1194 return false; 1194 return false;
1195 } 1195 }
1196 1196
1197 1197
1198 // static 1198 // static
1199 Handle<TemplateList> TemplateList::New(Isolate* isolate, int size) { 1199 Handle<TemplateList> TemplateList::New(Isolate* isolate, int size) {
1200 Handle<FixedArray> list = 1200 Handle<FixedArray> list =
1201 isolate->factory()->NewFixedArray(kLengthIndex + size); 1201 isolate->factory()->NewFixedArray(kLengthIndex + size);
1202 list->set(kLengthIndex, Smi::FromInt(0)); 1202 list->set(kLengthIndex, Smi::kZero);
1203 return Handle<TemplateList>::cast(list); 1203 return Handle<TemplateList>::cast(list);
1204 } 1204 }
1205 1205
1206 // static 1206 // static
1207 Handle<TemplateList> TemplateList::Add(Isolate* isolate, 1207 Handle<TemplateList> TemplateList::Add(Isolate* isolate,
1208 Handle<TemplateList> list, 1208 Handle<TemplateList> list,
1209 Handle<i::Object> value) { 1209 Handle<i::Object> value) {
1210 STATIC_ASSERT(kFirstElementIndex == 1); 1210 STATIC_ASSERT(kFirstElementIndex == 1);
1211 int index = list->length() + 1; 1211 int index = list->length() + 1;
1212 Handle<i::FixedArray> fixed_array = Handle<FixedArray>::cast(list); 1212 Handle<i::FixedArray> fixed_array = Handle<FixedArray>::cast(list);
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 if (v.value->IsSmi()) { 2145 if (v.value->IsSmi()) {
2146 Smi::cast(v.value)->SmiPrint(os); 2146 Smi::cast(v.value)->SmiPrint(os);
2147 } else { 2147 } else {
2148 // TODO(svenpanne) Const-correct HeapObjectShortPrint! 2148 // TODO(svenpanne) Const-correct HeapObjectShortPrint!
2149 HeapObject* obj = const_cast<HeapObject*>(HeapObject::cast(v.value)); 2149 HeapObject* obj = const_cast<HeapObject*>(HeapObject::cast(v.value));
2150 obj->HeapObjectShortPrint(os); 2150 obj->HeapObjectShortPrint(os);
2151 } 2151 }
2152 return os; 2152 return os;
2153 } 2153 }
2154 2154
2155 // Declaration of the static Smi::kZero constant.
2156 Smi* const Smi::kZero(nullptr);
2155 2157
2156 void Smi::SmiPrint(std::ostream& os) const { // NOLINT 2158 void Smi::SmiPrint(std::ostream& os) const { // NOLINT
2157 os << value(); 2159 os << value();
2158 } 2160 }
2159 2161
2160 2162
2161 // Should a word be prefixed by 'a' or 'an' in order to read naturally in 2163 // Should a word be prefixed by 'a' or 'an' in order to read naturally in
2162 // English? Returns false for non-ASCII or words that don't start with 2164 // English? Returns false for non-ASCII or words that don't start with
2163 // a capital letter. The a/an rule follows pronunciation in English. 2165 // a capital letter. The a/an rule follows pronunciation in English.
2164 // We don't use the BBC's overcorrect "an historic occasion" though if 2166 // We don't use the BBC's overcorrect "an historic occasion" though if
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 3170
3169 3171
3170 // static 3172 // static
3171 void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map, 3173 void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map,
3172 Handle<Map> new_map, 3174 Handle<Map> new_map,
3173 Isolate* isolate) { 3175 Isolate* isolate) {
3174 if (!old_map->is_prototype_map()) return; 3176 if (!old_map->is_prototype_map()) return;
3175 DCHECK(new_map->is_prototype_map()); 3177 DCHECK(new_map->is_prototype_map());
3176 bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate); 3178 bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate);
3177 new_map->set_prototype_info(old_map->prototype_info()); 3179 new_map->set_prototype_info(old_map->prototype_info());
3178 old_map->set_prototype_info(Smi::FromInt(0)); 3180 old_map->set_prototype_info(Smi::kZero);
3179 if (FLAG_trace_prototype_users) { 3181 if (FLAG_trace_prototype_users) {
3180 PrintF("Moving prototype_info %p from map %p to map %p.\n", 3182 PrintF("Moving prototype_info %p from map %p to map %p.\n",
3181 reinterpret_cast<void*>(new_map->prototype_info()), 3183 reinterpret_cast<void*>(new_map->prototype_info()),
3182 reinterpret_cast<void*>(*old_map), 3184 reinterpret_cast<void*>(*old_map),
3183 reinterpret_cast<void*>(*new_map)); 3185 reinterpret_cast<void*>(*new_map));
3184 } 3186 }
3185 if (was_registered) { 3187 if (was_registered) {
3186 if (new_map->prototype_info()->IsPrototypeInfo()) { 3188 if (new_map->prototype_info()->IsPrototypeInfo()) {
3187 // The new map isn't registered with its prototype yet; reflect this fact 3189 // The new map isn't registered with its prototype yet; reflect this fact
3188 // in the PrototypeInfo it just inherited from the old map. 3190 // in the PrototypeInfo it just inherited from the old map.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3324 FieldIndex index = FieldIndex::ForDescriptor(*old_map, i); 3326 FieldIndex index = FieldIndex::ForDescriptor(*old_map, i);
3325 if (object->IsUnboxedDoubleField(index)) { 3327 if (object->IsUnboxedDoubleField(index)) {
3326 double old = object->RawFastDoublePropertyAt(index); 3328 double old = object->RawFastDoublePropertyAt(index);
3327 value = isolate->factory()->NewHeapNumber( 3329 value = isolate->factory()->NewHeapNumber(
3328 old, representation.IsDouble() ? MUTABLE : IMMUTABLE); 3330 old, representation.IsDouble() ? MUTABLE : IMMUTABLE);
3329 3331
3330 } else { 3332 } else {
3331 value = handle(object->RawFastPropertyAt(index), isolate); 3333 value = handle(object->RawFastPropertyAt(index), isolate);
3332 if (!old_representation.IsDouble() && representation.IsDouble()) { 3334 if (!old_representation.IsDouble() && representation.IsDouble()) {
3333 if (old_representation.IsNone()) { 3335 if (old_representation.IsNone()) {
3334 value = handle(Smi::FromInt(0), isolate); 3336 value = handle(Smi::kZero, isolate);
3335 } 3337 }
3336 value = Object::NewStorageFor(isolate, value, representation); 3338 value = Object::NewStorageFor(isolate, value, representation);
3337 } else if (old_representation.IsDouble() && 3339 } else if (old_representation.IsDouble() &&
3338 !representation.IsDouble()) { 3340 !representation.IsDouble()) {
3339 value = Object::WrapForRead(isolate, value, old_representation); 3341 value = Object::WrapForRead(isolate, value, old_representation);
3340 } 3342 }
3341 } 3343 }
3342 } 3344 }
3343 DCHECK(!(representation.IsDouble() && value->IsSmi())); 3345 DCHECK(!(representation.IsDouble() && value->IsSmi()));
3344 int target_index = new_descriptors->GetFieldIndex(i) - inobject; 3346 int target_index = new_descriptors->GetFieldIndex(i) - inobject;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 // the left-over space to avoid races with the sweeper thread. 3509 // the left-over space to avoid races with the sweeper thread.
3508 object->synchronized_set_map(*new_map); 3510 object->synchronized_set_map(*new_map);
3509 3511
3510 object->set_properties(*dictionary); 3512 object->set_properties(*dictionary);
3511 3513
3512 // Ensure that in-object space of slow-mode object does not contain random 3514 // Ensure that in-object space of slow-mode object does not contain random
3513 // garbage. 3515 // garbage.
3514 int inobject_properties = new_map->GetInObjectProperties(); 3516 int inobject_properties = new_map->GetInObjectProperties();
3515 for (int i = 0; i < inobject_properties; i++) { 3517 for (int i = 0; i < inobject_properties; i++) {
3516 FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i); 3518 FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i);
3517 object->RawFastPropertyAtPut(index, Smi::FromInt(0)); 3519 object->RawFastPropertyAtPut(index, Smi::kZero);
3518 } 3520 }
3519 3521
3520 isolate->counters()->props_to_dictionary()->Increment(); 3522 isolate->counters()->props_to_dictionary()->Increment();
3521 3523
3522 #ifdef DEBUG 3524 #ifdef DEBUG
3523 if (FLAG_trace_normalization) { 3525 if (FLAG_trace_normalization) {
3524 OFStream os(stdout); 3526 OFStream os(stdout);
3525 os << "Object properties have been normalized:\n"; 3527 os << "Object properties have been normalized:\n";
3526 object->Print(os); 3528 object->Print(os);
3527 } 3529 }
(...skipping 5365 matching lines...) Expand 10 before | Expand all | Expand 10 after
8893 if (FLAG_enable_slow_asserts) { 8895 if (FLAG_enable_slow_asserts) {
8894 // The cached map should match newly created normalized map bit-by-bit, 8896 // The cached map should match newly created normalized map bit-by-bit,
8895 // except for the code cache, which can contain some ics which can be 8897 // except for the code cache, which can contain some ics which can be
8896 // applied to the shared map, dependent code and weak cell cache. 8898 // applied to the shared map, dependent code and weak cell cache.
8897 Handle<Map> fresh = Map::CopyNormalized(fast_map, mode); 8899 Handle<Map> fresh = Map::CopyNormalized(fast_map, mode);
8898 8900
8899 if (new_map->is_prototype_map()) { 8901 if (new_map->is_prototype_map()) {
8900 // For prototype maps, the PrototypeInfo is not copied. 8902 // For prototype maps, the PrototypeInfo is not copied.
8901 DCHECK(memcmp(fresh->address(), new_map->address(), 8903 DCHECK(memcmp(fresh->address(), new_map->address(),
8902 kTransitionsOrPrototypeInfoOffset) == 0); 8904 kTransitionsOrPrototypeInfoOffset) == 0);
8903 DCHECK(fresh->raw_transitions() == Smi::FromInt(0)); 8905 DCHECK(fresh->raw_transitions() == Smi::kZero);
8904 STATIC_ASSERT(kDescriptorsOffset == 8906 STATIC_ASSERT(kDescriptorsOffset ==
8905 kTransitionsOrPrototypeInfoOffset + kPointerSize); 8907 kTransitionsOrPrototypeInfoOffset + kPointerSize);
8906 DCHECK(memcmp(HeapObject::RawField(*fresh, kDescriptorsOffset), 8908 DCHECK(memcmp(HeapObject::RawField(*fresh, kDescriptorsOffset),
8907 HeapObject::RawField(*new_map, kDescriptorsOffset), 8909 HeapObject::RawField(*new_map, kDescriptorsOffset),
8908 kCodeCacheOffset - kDescriptorsOffset) == 0); 8910 kCodeCacheOffset - kDescriptorsOffset) == 0);
8909 } else { 8911 } else {
8910 DCHECK(memcmp(fresh->address(), new_map->address(), 8912 DCHECK(memcmp(fresh->address(), new_map->address(),
8911 Map::kCodeCacheOffset) == 0); 8913 Map::kCodeCacheOffset) == 0);
8912 } 8914 }
8913 STATIC_ASSERT(Map::kDependentCodeOffset == 8915 STATIC_ASSERT(Map::kDependentCodeOffset ==
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
10250 DCHECK(initialize_from->Length() <= size); 10252 DCHECK(initialize_from->Length() <= size);
10251 Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from); 10253 Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from);
10252 // Copy the entries without compacting, since the PrototypeInfo relies on 10254 // Copy the entries without compacting, since the PrototypeInfo relies on
10253 // the index of the entries not to change. 10255 // the index of the entries not to change.
10254 while (index < raw_source->length()) { 10256 while (index < raw_source->length()) {
10255 result->set(index, raw_source->get(index)); 10257 result->set(index, raw_source->get(index));
10256 index++; 10258 index++;
10257 } 10259 }
10258 } 10260 }
10259 while (index < result->length()) { 10261 while (index < result->length()) {
10260 result->set(index, Smi::FromInt(0)); 10262 result->set(index, Smi::kZero);
10261 index++; 10263 index++;
10262 } 10264 }
10263 return Handle<WeakFixedArray>::cast(result); 10265 return Handle<WeakFixedArray>::cast(result);
10264 } 10266 }
10265 10267
10266 10268
10267 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj, 10269 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj,
10268 AddMode mode) { 10270 AddMode mode) {
10269 int length = array->Length(); 10271 int length = array->Length();
10270 array = EnsureSpace(array, length + 1); 10272 array = EnsureSpace(array, length + 1);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
10373 DCHECK(0 <= number_of_descriptors); 10375 DCHECK(0 <= number_of_descriptors);
10374 Factory* factory = isolate->factory(); 10376 Factory* factory = isolate->factory();
10375 // Do not use DescriptorArray::cast on incomplete object. 10377 // Do not use DescriptorArray::cast on incomplete object.
10376 int size = number_of_descriptors + slack; 10378 int size = number_of_descriptors + slack;
10377 if (size == 0) return factory->empty_descriptor_array(); 10379 if (size == 0) return factory->empty_descriptor_array();
10378 // Allocate the array of keys. 10380 // Allocate the array of keys.
10379 Handle<FixedArray> result = 10381 Handle<FixedArray> result =
10380 factory->NewFixedArray(LengthFor(size), pretenure); 10382 factory->NewFixedArray(LengthFor(size), pretenure);
10381 10383
10382 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors)); 10384 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors));
10383 result->set(kEnumCacheIndex, Smi::FromInt(0)); 10385 result->set(kEnumCacheIndex, Smi::kZero);
10384 return Handle<DescriptorArray>::cast(result); 10386 return Handle<DescriptorArray>::cast(result);
10385 } 10387 }
10386 10388
10387 10389 void DescriptorArray::ClearEnumCache() { set(kEnumCacheIndex, Smi::kZero); }
10388 void DescriptorArray::ClearEnumCache() {
10389 set(kEnumCacheIndex, Smi::FromInt(0));
10390 }
10391
10392 10390
10393 void DescriptorArray::Replace(int index, Descriptor* descriptor) { 10391 void DescriptorArray::Replace(int index, Descriptor* descriptor) {
10394 descriptor->SetSortedKeyIndex(GetSortedKeyIndex(index)); 10392 descriptor->SetSortedKeyIndex(GetSortedKeyIndex(index));
10395 Set(index, descriptor); 10393 Set(index, descriptor);
10396 } 10394 }
10397 10395
10398 10396
10399 // static 10397 // static
10400 void DescriptorArray::SetEnumCache(Handle<DescriptorArray> descriptors, 10398 void DescriptorArray::SetEnumCache(Handle<DescriptorArray> descriptors,
10401 Isolate* isolate, 10399 Isolate* isolate,
10402 Handle<FixedArray> new_cache, 10400 Handle<FixedArray> new_cache,
10403 Handle<FixedArray> new_index_cache) { 10401 Handle<FixedArray> new_index_cache) {
10404 DCHECK(!descriptors->IsEmpty()); 10402 DCHECK(!descriptors->IsEmpty());
10405 FixedArray* bridge_storage; 10403 FixedArray* bridge_storage;
10406 bool needs_new_enum_cache = !descriptors->HasEnumCache(); 10404 bool needs_new_enum_cache = !descriptors->HasEnumCache();
10407 if (needs_new_enum_cache) { 10405 if (needs_new_enum_cache) {
10408 bridge_storage = *isolate->factory()->NewFixedArray( 10406 bridge_storage = *isolate->factory()->NewFixedArray(
10409 DescriptorArray::kEnumCacheBridgeLength); 10407 DescriptorArray::kEnumCacheBridgeLength);
10410 } else { 10408 } else {
10411 bridge_storage = FixedArray::cast(descriptors->get(kEnumCacheIndex)); 10409 bridge_storage = FixedArray::cast(descriptors->get(kEnumCacheIndex));
10412 } 10410 }
10413 bridge_storage->set(kEnumCacheBridgeCacheIndex, *new_cache); 10411 bridge_storage->set(kEnumCacheBridgeCacheIndex, *new_cache);
10414 bridge_storage->set(kEnumCacheBridgeIndicesCacheIndex, 10412 bridge_storage->set(
10415 new_index_cache.is_null() ? Object::cast(Smi::FromInt(0)) 10413 kEnumCacheBridgeIndicesCacheIndex,
10416 : *new_index_cache); 10414 new_index_cache.is_null() ? Object::cast(Smi::kZero) : *new_index_cache);
10417 if (needs_new_enum_cache) { 10415 if (needs_new_enum_cache) {
10418 descriptors->set(kEnumCacheIndex, bridge_storage); 10416 descriptors->set(kEnumCacheIndex, bridge_storage);
10419 } 10417 }
10420 } 10418 }
10421 10419
10422 10420
10423 void DescriptorArray::CopyFrom(int index, DescriptorArray* src) { 10421 void DescriptorArray::CopyFrom(int index, DescriptorArray* src) {
10424 Object* value = src->GetValue(index); 10422 Object* value = src->GetValue(index);
10425 PropertyDetails details = src->GetDetails(index); 10423 PropertyDetails details = src->GetDetails(index);
10426 Descriptor desc(handle(src->GetKey(index)), 10424 Descriptor desc(handle(src->GetKey(index)),
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
10708 10706
10709 // Fast array index case. 10707 // Fast array index case.
10710 uint32_t index; 10708 uint32_t index;
10711 if (subject->AsArrayIndex(&index)) { 10709 if (subject->AsArrayIndex(&index)) {
10712 return isolate->factory()->NewNumberFromUint(index); 10710 return isolate->factory()->NewNumberFromUint(index);
10713 } 10711 }
10714 10712
10715 // Fast case: short integer or some sorts of junk values. 10713 // Fast case: short integer or some sorts of junk values.
10716 if (subject->IsSeqOneByteString()) { 10714 if (subject->IsSeqOneByteString()) {
10717 int len = subject->length(); 10715 int len = subject->length();
10718 if (len == 0) return handle(Smi::FromInt(0), isolate); 10716 if (len == 0) return handle(Smi::kZero, isolate);
10719 10717
10720 DisallowHeapAllocation no_gc; 10718 DisallowHeapAllocation no_gc;
10721 uint8_t const* data = Handle<SeqOneByteString>::cast(subject)->GetChars(); 10719 uint8_t const* data = Handle<SeqOneByteString>::cast(subject)->GetChars();
10722 bool minus = (data[0] == '-'); 10720 bool minus = (data[0] == '-');
10723 int start_pos = (minus ? 1 : 0); 10721 int start_pos = (minus ? 1 : 0);
10724 10722
10725 if (start_pos == len) { 10723 if (start_pos == len) {
10726 return isolate->factory()->nan_value(); 10724 return isolate->factory()->nan_value();
10727 } else if (data[start_pos] > '9') { 10725 } else if (data[start_pos] > '9') {
10728 // Fast check for a junk value. A valid string may start from a 10726 // Fast check for a junk value. A valid string may start from a
(...skipping 5797 matching lines...) Expand 10 before | Expand all | Expand 10 after
16526 JSRegExp); 16524 JSRegExp);
16527 16525
16528 regexp->set_source(*escaped_source); 16526 regexp->set_source(*escaped_source);
16529 regexp->set_flags(Smi::FromInt(flags)); 16527 regexp->set_flags(Smi::FromInt(flags));
16530 16528
16531 Map* map = regexp->map(); 16529 Map* map = regexp->map();
16532 Object* constructor = map->GetConstructor(); 16530 Object* constructor = map->GetConstructor();
16533 if (constructor->IsJSFunction() && 16531 if (constructor->IsJSFunction() &&
16534 JSFunction::cast(constructor)->initial_map() == map) { 16532 JSFunction::cast(constructor)->initial_map() == map) {
16535 // If we still have the original map, set in-object properties directly. 16533 // If we still have the original map, set in-object properties directly.
16536 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, 16534 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, Smi::kZero,
16537 Smi::FromInt(0), SKIP_WRITE_BARRIER); 16535 SKIP_WRITE_BARRIER);
16538 } else { 16536 } else {
16539 // Map has changed, so use generic, but slower, method. 16537 // Map has changed, so use generic, but slower, method.
16540 RETURN_ON_EXCEPTION( 16538 RETURN_ON_EXCEPTION(isolate, JSReceiver::SetProperty(
16541 isolate, 16539 regexp, factory->last_index_string(),
16542 JSReceiver::SetProperty(regexp, factory->last_index_string(), 16540 Handle<Smi>(Smi::kZero, isolate), STRICT),
16543 Handle<Smi>(Smi::FromInt(0), isolate), STRICT), 16541 JSRegExp);
16544 JSRegExp);
16545 } 16542 }
16546 16543
16547 return regexp; 16544 return regexp;
16548 } 16545 }
16549 16546
16550 16547
16551 // RegExpKey carries the source and flags of a regular expression as key. 16548 // RegExpKey carries the source and flags of a regular expression as key.
16552 class RegExpKey : public HashTableKey { 16549 class RegExpKey : public HashTableKey {
16553 public: 16550 public:
16554 RegExpKey(Handle<String> string, JSRegExp::Flags flags) 16551 RegExpKey(Handle<String> string, JSRegExp::Flags flags)
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
17250 17247
17251 // Collect holes at the end, undefined before that and the rest at the 17248 // Collect holes at the end, undefined before that and the rest at the
17252 // start, and return the number of non-hole, non-undefined values. 17249 // start, and return the number of non-hole, non-undefined values.
17253 17250
17254 Handle<FixedArrayBase> elements_base(object->elements()); 17251 Handle<FixedArrayBase> elements_base(object->elements());
17255 uint32_t elements_length = static_cast<uint32_t>(elements_base->length()); 17252 uint32_t elements_length = static_cast<uint32_t>(elements_base->length());
17256 if (limit > elements_length) { 17253 if (limit > elements_length) {
17257 limit = elements_length; 17254 limit = elements_length;
17258 } 17255 }
17259 if (limit == 0) { 17256 if (limit == 0) {
17260 return handle(Smi::FromInt(0), isolate); 17257 return handle(Smi::kZero, isolate);
17261 } 17258 }
17262 17259
17263 uint32_t result = 0; 17260 uint32_t result = 0;
17264 if (elements_base->map() == isolate->heap()->fixed_double_array_map()) { 17261 if (elements_base->map() == isolate->heap()->fixed_double_array_map()) {
17265 FixedDoubleArray* elements = FixedDoubleArray::cast(*elements_base); 17262 FixedDoubleArray* elements = FixedDoubleArray::cast(*elements_base);
17266 // Split elements into defined and the_hole, in that order. 17263 // Split elements into defined and the_hole, in that order.
17267 unsigned int holes = limit; 17264 unsigned int holes = limit;
17268 // Assume most arrays contain no holes and undefined values, so minimize the 17265 // Assume most arrays contain no holes and undefined values, so minimize the
17269 // number of stores of non-undefined, non-the-hole values. 17266 // number of stores of non-undefined, non-the-hole values.
17270 for (unsigned int i = 0; i < holes; i++) { 17267 for (unsigned int i = 0; i < holes; i++) {
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
18673 18670
18674 template<class Derived, class TableType> 18671 template<class Derived, class TableType>
18675 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) { 18672 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) {
18676 DisallowHeapAllocation no_allocation; 18673 DisallowHeapAllocation no_allocation;
18677 if (HasMore()) { 18674 if (HasMore()) {
18678 FixedArray* array = FixedArray::cast(value_array->elements()); 18675 FixedArray* array = FixedArray::cast(value_array->elements());
18679 static_cast<Derived*>(this)->PopulateValueArray(array); 18676 static_cast<Derived*>(this)->PopulateValueArray(array);
18680 MoveNext(); 18677 MoveNext();
18681 return Smi::cast(kind()); 18678 return Smi::cast(kind());
18682 } 18679 }
18683 return Smi::FromInt(0); 18680 return Smi::kZero;
18684 } 18681 }
18685 18682
18686 18683
18687 template Smi* 18684 template Smi*
18688 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::Next( 18685 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::Next(
18689 JSArray* value_array); 18686 JSArray* value_array);
18690 18687
18691 template bool 18688 template bool
18692 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::HasMore(); 18689 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::HasMore();
18693 18690
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
19279 } 19276 }
19280 19277
19281 Handle<String> src = handle(String::cast(the_script->source()), isolate); 19278 Handle<String> src = handle(String::cast(the_script->source()), isolate);
19282 return isolate->factory()->NewSubString(src, info.line_start, info.line_end); 19279 return isolate->factory()->NewSubString(src, info.line_start, info.line_end);
19283 } 19280 }
19284 19281
19285 void JSArrayBuffer::Neuter() { 19282 void JSArrayBuffer::Neuter() {
19286 CHECK(is_neuterable()); 19283 CHECK(is_neuterable());
19287 CHECK(is_external()); 19284 CHECK(is_external());
19288 set_backing_store(NULL); 19285 set_backing_store(NULL);
19289 set_byte_length(Smi::FromInt(0)); 19286 set_byte_length(Smi::kZero);
19290 set_was_neutered(true); 19287 set_was_neutered(true);
19291 } 19288 }
19292 19289
19293 19290
19294 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, 19291 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate,
19295 bool is_external, void* data, size_t allocated_length, 19292 bool is_external, void* data, size_t allocated_length,
19296 SharedFlag shared) { 19293 SharedFlag shared) {
19297 DCHECK(array_buffer->GetInternalFieldCount() == 19294 DCHECK(array_buffer->GetInternalFieldCount() ==
19298 v8::ArrayBuffer::kInternalFieldCount); 19295 v8::ArrayBuffer::kInternalFieldCount);
19299 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { 19296 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
19300 array_buffer->SetInternalField(i, Smi::FromInt(0)); 19297 array_buffer->SetInternalField(i, Smi::kZero);
19301 } 19298 }
19302 array_buffer->set_bit_field(0); 19299 array_buffer->set_bit_field(0);
19303 array_buffer->set_is_external(is_external); 19300 array_buffer->set_is_external(is_external);
19304 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); 19301 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared);
19305 array_buffer->set_is_shared(shared == SharedFlag::kShared); 19302 array_buffer->set_is_shared(shared == SharedFlag::kShared);
19306 19303
19307 Handle<Object> byte_length = 19304 Handle<Object> byte_length =
19308 isolate->factory()->NewNumberFromSize(allocated_length); 19305 isolate->factory()->NewNumberFromSize(allocated_length);
19309 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); 19306 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
19310 array_buffer->set_byte_length(*byte_length); 19307 array_buffer->set_byte_length(*byte_length);
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
19933 } 19930 }
19934 19931
19935 // Evaluation of module body. 19932 // Evaluation of module body.
19936 Handle<JSFunction> resume( 19933 Handle<JSFunction> resume(
19937 isolate->native_context()->generator_next_internal(), isolate); 19934 isolate->native_context()->generator_next_internal(), isolate);
19938 return Execution::Call(isolate, resume, generator, 0, nullptr); 19935 return Execution::Call(isolate, resume, generator, 0, nullptr);
19939 } 19936 }
19940 19937
19941 } // namespace internal 19938 } // namespace internal
19942 } // namespace v8 19939 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698