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

Side by Side Diff: src/objects.cc

Issue 2396353002: Revert "Add Smi::Zero and replace all Smi::FromInt(0) calls" (Closed)
Patch Set: 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::kZero); 1202 list->set(kLengthIndex, Smi::FromInt(0));
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);
2157 2155
2158 void Smi::SmiPrint(std::ostream& os) const { // NOLINT 2156 void Smi::SmiPrint(std::ostream& os) const { // NOLINT
2159 os << value(); 2157 os << value();
2160 } 2158 }
2161 2159
2162 2160
2163 // Should a word be prefixed by 'a' or 'an' in order to read naturally in 2161 // Should a word be prefixed by 'a' or 'an' in order to read naturally in
2164 // English? Returns false for non-ASCII or words that don't start with 2162 // English? Returns false for non-ASCII or words that don't start with
2165 // a capital letter. The a/an rule follows pronunciation in English. 2163 // a capital letter. The a/an rule follows pronunciation in English.
2166 // We don't use the BBC's overcorrect "an historic occasion" though if 2164 // 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
3170 3168
3171 3169
3172 // static 3170 // static
3173 void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map, 3171 void JSObject::UpdatePrototypeUserRegistration(Handle<Map> old_map,
3174 Handle<Map> new_map, 3172 Handle<Map> new_map,
3175 Isolate* isolate) { 3173 Isolate* isolate) {
3176 if (!old_map->is_prototype_map()) return; 3174 if (!old_map->is_prototype_map()) return;
3177 DCHECK(new_map->is_prototype_map()); 3175 DCHECK(new_map->is_prototype_map());
3178 bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate); 3176 bool was_registered = JSObject::UnregisterPrototypeUser(old_map, isolate);
3179 new_map->set_prototype_info(old_map->prototype_info()); 3177 new_map->set_prototype_info(old_map->prototype_info());
3180 old_map->set_prototype_info(Smi::kZero); 3178 old_map->set_prototype_info(Smi::FromInt(0));
3181 if (FLAG_trace_prototype_users) { 3179 if (FLAG_trace_prototype_users) {
3182 PrintF("Moving prototype_info %p from map %p to map %p.\n", 3180 PrintF("Moving prototype_info %p from map %p to map %p.\n",
3183 reinterpret_cast<void*>(new_map->prototype_info()), 3181 reinterpret_cast<void*>(new_map->prototype_info()),
3184 reinterpret_cast<void*>(*old_map), 3182 reinterpret_cast<void*>(*old_map),
3185 reinterpret_cast<void*>(*new_map)); 3183 reinterpret_cast<void*>(*new_map));
3186 } 3184 }
3187 if (was_registered) { 3185 if (was_registered) {
3188 if (new_map->prototype_info()->IsPrototypeInfo()) { 3186 if (new_map->prototype_info()->IsPrototypeInfo()) {
3189 // The new map isn't registered with its prototype yet; reflect this fact 3187 // The new map isn't registered with its prototype yet; reflect this fact
3190 // in the PrototypeInfo it just inherited from the old map. 3188 // in the PrototypeInfo it just inherited from the old map.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 FieldIndex index = FieldIndex::ForDescriptor(*old_map, i); 3324 FieldIndex index = FieldIndex::ForDescriptor(*old_map, i);
3327 if (object->IsUnboxedDoubleField(index)) { 3325 if (object->IsUnboxedDoubleField(index)) {
3328 double old = object->RawFastDoublePropertyAt(index); 3326 double old = object->RawFastDoublePropertyAt(index);
3329 value = isolate->factory()->NewHeapNumber( 3327 value = isolate->factory()->NewHeapNumber(
3330 old, representation.IsDouble() ? MUTABLE : IMMUTABLE); 3328 old, representation.IsDouble() ? MUTABLE : IMMUTABLE);
3331 3329
3332 } else { 3330 } else {
3333 value = handle(object->RawFastPropertyAt(index), isolate); 3331 value = handle(object->RawFastPropertyAt(index), isolate);
3334 if (!old_representation.IsDouble() && representation.IsDouble()) { 3332 if (!old_representation.IsDouble() && representation.IsDouble()) {
3335 if (old_representation.IsNone()) { 3333 if (old_representation.IsNone()) {
3336 value = handle(Smi::kZero, isolate); 3334 value = handle(Smi::FromInt(0), isolate);
3337 } 3335 }
3338 value = Object::NewStorageFor(isolate, value, representation); 3336 value = Object::NewStorageFor(isolate, value, representation);
3339 } else if (old_representation.IsDouble() && 3337 } else if (old_representation.IsDouble() &&
3340 !representation.IsDouble()) { 3338 !representation.IsDouble()) {
3341 value = Object::WrapForRead(isolate, value, old_representation); 3339 value = Object::WrapForRead(isolate, value, old_representation);
3342 } 3340 }
3343 } 3341 }
3344 } 3342 }
3345 DCHECK(!(representation.IsDouble() && value->IsSmi())); 3343 DCHECK(!(representation.IsDouble() && value->IsSmi()));
3346 int target_index = new_descriptors->GetFieldIndex(i) - inobject; 3344 int target_index = new_descriptors->GetFieldIndex(i) - inobject;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 // the left-over space to avoid races with the sweeper thread. 3507 // the left-over space to avoid races with the sweeper thread.
3510 object->synchronized_set_map(*new_map); 3508 object->synchronized_set_map(*new_map);
3511 3509
3512 object->set_properties(*dictionary); 3510 object->set_properties(*dictionary);
3513 3511
3514 // Ensure that in-object space of slow-mode object does not contain random 3512 // Ensure that in-object space of slow-mode object does not contain random
3515 // garbage. 3513 // garbage.
3516 int inobject_properties = new_map->GetInObjectProperties(); 3514 int inobject_properties = new_map->GetInObjectProperties();
3517 for (int i = 0; i < inobject_properties; i++) { 3515 for (int i = 0; i < inobject_properties; i++) {
3518 FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i); 3516 FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i);
3519 object->RawFastPropertyAtPut(index, Smi::kZero); 3517 object->RawFastPropertyAtPut(index, Smi::FromInt(0));
3520 } 3518 }
3521 3519
3522 isolate->counters()->props_to_dictionary()->Increment(); 3520 isolate->counters()->props_to_dictionary()->Increment();
3523 3521
3524 #ifdef DEBUG 3522 #ifdef DEBUG
3525 if (FLAG_trace_normalization) { 3523 if (FLAG_trace_normalization) {
3526 OFStream os(stdout); 3524 OFStream os(stdout);
3527 os << "Object properties have been normalized:\n"; 3525 os << "Object properties have been normalized:\n";
3528 object->Print(os); 3526 object->Print(os);
3529 } 3527 }
(...skipping 5365 matching lines...) Expand 10 before | Expand all | Expand 10 after
8895 if (FLAG_enable_slow_asserts) { 8893 if (FLAG_enable_slow_asserts) {
8896 // The cached map should match newly created normalized map bit-by-bit, 8894 // The cached map should match newly created normalized map bit-by-bit,
8897 // except for the code cache, which can contain some ics which can be 8895 // except for the code cache, which can contain some ics which can be
8898 // applied to the shared map, dependent code and weak cell cache. 8896 // applied to the shared map, dependent code and weak cell cache.
8899 Handle<Map> fresh = Map::CopyNormalized(fast_map, mode); 8897 Handle<Map> fresh = Map::CopyNormalized(fast_map, mode);
8900 8898
8901 if (new_map->is_prototype_map()) { 8899 if (new_map->is_prototype_map()) {
8902 // For prototype maps, the PrototypeInfo is not copied. 8900 // For prototype maps, the PrototypeInfo is not copied.
8903 DCHECK(memcmp(fresh->address(), new_map->address(), 8901 DCHECK(memcmp(fresh->address(), new_map->address(),
8904 kTransitionsOrPrototypeInfoOffset) == 0); 8902 kTransitionsOrPrototypeInfoOffset) == 0);
8905 DCHECK(fresh->raw_transitions() == Smi::kZero); 8903 DCHECK(fresh->raw_transitions() == Smi::FromInt(0));
8906 STATIC_ASSERT(kDescriptorsOffset == 8904 STATIC_ASSERT(kDescriptorsOffset ==
8907 kTransitionsOrPrototypeInfoOffset + kPointerSize); 8905 kTransitionsOrPrototypeInfoOffset + kPointerSize);
8908 DCHECK(memcmp(HeapObject::RawField(*fresh, kDescriptorsOffset), 8906 DCHECK(memcmp(HeapObject::RawField(*fresh, kDescriptorsOffset),
8909 HeapObject::RawField(*new_map, kDescriptorsOffset), 8907 HeapObject::RawField(*new_map, kDescriptorsOffset),
8910 kCodeCacheOffset - kDescriptorsOffset) == 0); 8908 kCodeCacheOffset - kDescriptorsOffset) == 0);
8911 } else { 8909 } else {
8912 DCHECK(memcmp(fresh->address(), new_map->address(), 8910 DCHECK(memcmp(fresh->address(), new_map->address(),
8913 Map::kCodeCacheOffset) == 0); 8911 Map::kCodeCacheOffset) == 0);
8914 } 8912 }
8915 STATIC_ASSERT(Map::kDependentCodeOffset == 8913 STATIC_ASSERT(Map::kDependentCodeOffset ==
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
10252 DCHECK(initialize_from->Length() <= size); 10250 DCHECK(initialize_from->Length() <= size);
10253 Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from); 10251 Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from);
10254 // Copy the entries without compacting, since the PrototypeInfo relies on 10252 // Copy the entries without compacting, since the PrototypeInfo relies on
10255 // the index of the entries not to change. 10253 // the index of the entries not to change.
10256 while (index < raw_source->length()) { 10254 while (index < raw_source->length()) {
10257 result->set(index, raw_source->get(index)); 10255 result->set(index, raw_source->get(index));
10258 index++; 10256 index++;
10259 } 10257 }
10260 } 10258 }
10261 while (index < result->length()) { 10259 while (index < result->length()) {
10262 result->set(index, Smi::kZero); 10260 result->set(index, Smi::FromInt(0));
10263 index++; 10261 index++;
10264 } 10262 }
10265 return Handle<WeakFixedArray>::cast(result); 10263 return Handle<WeakFixedArray>::cast(result);
10266 } 10264 }
10267 10265
10268 10266
10269 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj, 10267 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj,
10270 AddMode mode) { 10268 AddMode mode) {
10271 int length = array->Length(); 10269 int length = array->Length();
10272 array = EnsureSpace(array, length + 1); 10270 array = EnsureSpace(array, length + 1);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
10375 DCHECK(0 <= number_of_descriptors); 10373 DCHECK(0 <= number_of_descriptors);
10376 Factory* factory = isolate->factory(); 10374 Factory* factory = isolate->factory();
10377 // Do not use DescriptorArray::cast on incomplete object. 10375 // Do not use DescriptorArray::cast on incomplete object.
10378 int size = number_of_descriptors + slack; 10376 int size = number_of_descriptors + slack;
10379 if (size == 0) return factory->empty_descriptor_array(); 10377 if (size == 0) return factory->empty_descriptor_array();
10380 // Allocate the array of keys. 10378 // Allocate the array of keys.
10381 Handle<FixedArray> result = 10379 Handle<FixedArray> result =
10382 factory->NewFixedArray(LengthFor(size), pretenure); 10380 factory->NewFixedArray(LengthFor(size), pretenure);
10383 10381
10384 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors)); 10382 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors));
10385 result->set(kEnumCacheIndex, Smi::kZero); 10383 result->set(kEnumCacheIndex, Smi::FromInt(0));
10386 return Handle<DescriptorArray>::cast(result); 10384 return Handle<DescriptorArray>::cast(result);
10387 } 10385 }
10388 10386
10389 void DescriptorArray::ClearEnumCache() { set(kEnumCacheIndex, Smi::kZero); } 10387
10388 void DescriptorArray::ClearEnumCache() {
10389 set(kEnumCacheIndex, Smi::FromInt(0));
10390 }
10391
10390 10392
10391 void DescriptorArray::Replace(int index, Descriptor* descriptor) { 10393 void DescriptorArray::Replace(int index, Descriptor* descriptor) {
10392 descriptor->SetSortedKeyIndex(GetSortedKeyIndex(index)); 10394 descriptor->SetSortedKeyIndex(GetSortedKeyIndex(index));
10393 Set(index, descriptor); 10395 Set(index, descriptor);
10394 } 10396 }
10395 10397
10396 10398
10397 // static 10399 // static
10398 void DescriptorArray::SetEnumCache(Handle<DescriptorArray> descriptors, 10400 void DescriptorArray::SetEnumCache(Handle<DescriptorArray> descriptors,
10399 Isolate* isolate, 10401 Isolate* isolate,
10400 Handle<FixedArray> new_cache, 10402 Handle<FixedArray> new_cache,
10401 Handle<FixedArray> new_index_cache) { 10403 Handle<FixedArray> new_index_cache) {
10402 DCHECK(!descriptors->IsEmpty()); 10404 DCHECK(!descriptors->IsEmpty());
10403 FixedArray* bridge_storage; 10405 FixedArray* bridge_storage;
10404 bool needs_new_enum_cache = !descriptors->HasEnumCache(); 10406 bool needs_new_enum_cache = !descriptors->HasEnumCache();
10405 if (needs_new_enum_cache) { 10407 if (needs_new_enum_cache) {
10406 bridge_storage = *isolate->factory()->NewFixedArray( 10408 bridge_storage = *isolate->factory()->NewFixedArray(
10407 DescriptorArray::kEnumCacheBridgeLength); 10409 DescriptorArray::kEnumCacheBridgeLength);
10408 } else { 10410 } else {
10409 bridge_storage = FixedArray::cast(descriptors->get(kEnumCacheIndex)); 10411 bridge_storage = FixedArray::cast(descriptors->get(kEnumCacheIndex));
10410 } 10412 }
10411 bridge_storage->set(kEnumCacheBridgeCacheIndex, *new_cache); 10413 bridge_storage->set(kEnumCacheBridgeCacheIndex, *new_cache);
10412 bridge_storage->set( 10414 bridge_storage->set(kEnumCacheBridgeIndicesCacheIndex,
10413 kEnumCacheBridgeIndicesCacheIndex, 10415 new_index_cache.is_null() ? Object::cast(Smi::FromInt(0))
10414 new_index_cache.is_null() ? Object::cast(Smi::kZero) : *new_index_cache); 10416 : *new_index_cache);
10415 if (needs_new_enum_cache) { 10417 if (needs_new_enum_cache) {
10416 descriptors->set(kEnumCacheIndex, bridge_storage); 10418 descriptors->set(kEnumCacheIndex, bridge_storage);
10417 } 10419 }
10418 } 10420 }
10419 10421
10420 10422
10421 void DescriptorArray::CopyFrom(int index, DescriptorArray* src) { 10423 void DescriptorArray::CopyFrom(int index, DescriptorArray* src) {
10422 Object* value = src->GetValue(index); 10424 Object* value = src->GetValue(index);
10423 PropertyDetails details = src->GetDetails(index); 10425 PropertyDetails details = src->GetDetails(index);
10424 Descriptor desc(handle(src->GetKey(index)), 10426 Descriptor desc(handle(src->GetKey(index)),
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
10706 10708
10707 // Fast array index case. 10709 // Fast array index case.
10708 uint32_t index; 10710 uint32_t index;
10709 if (subject->AsArrayIndex(&index)) { 10711 if (subject->AsArrayIndex(&index)) {
10710 return isolate->factory()->NewNumberFromUint(index); 10712 return isolate->factory()->NewNumberFromUint(index);
10711 } 10713 }
10712 10714
10713 // Fast case: short integer or some sorts of junk values. 10715 // Fast case: short integer or some sorts of junk values.
10714 if (subject->IsSeqOneByteString()) { 10716 if (subject->IsSeqOneByteString()) {
10715 int len = subject->length(); 10717 int len = subject->length();
10716 if (len == 0) return handle(Smi::kZero, isolate); 10718 if (len == 0) return handle(Smi::FromInt(0), isolate);
10717 10719
10718 DisallowHeapAllocation no_gc; 10720 DisallowHeapAllocation no_gc;
10719 uint8_t const* data = Handle<SeqOneByteString>::cast(subject)->GetChars(); 10721 uint8_t const* data = Handle<SeqOneByteString>::cast(subject)->GetChars();
10720 bool minus = (data[0] == '-'); 10722 bool minus = (data[0] == '-');
10721 int start_pos = (minus ? 1 : 0); 10723 int start_pos = (minus ? 1 : 0);
10722 10724
10723 if (start_pos == len) { 10725 if (start_pos == len) {
10724 return isolate->factory()->nan_value(); 10726 return isolate->factory()->nan_value();
10725 } else if (data[start_pos] > '9') { 10727 } else if (data[start_pos] > '9') {
10726 // Fast check for a junk value. A valid string may start from a 10728 // Fast check for a junk value. A valid string may start from a
(...skipping 5749 matching lines...) Expand 10 before | Expand all | Expand 10 after
16476 JSRegExp); 16478 JSRegExp);
16477 16479
16478 regexp->set_source(*escaped_source); 16480 regexp->set_source(*escaped_source);
16479 regexp->set_flags(Smi::FromInt(flags)); 16481 regexp->set_flags(Smi::FromInt(flags));
16480 16482
16481 Map* map = regexp->map(); 16483 Map* map = regexp->map();
16482 Object* constructor = map->GetConstructor(); 16484 Object* constructor = map->GetConstructor();
16483 if (constructor->IsJSFunction() && 16485 if (constructor->IsJSFunction() &&
16484 JSFunction::cast(constructor)->initial_map() == map) { 16486 JSFunction::cast(constructor)->initial_map() == map) {
16485 // If we still have the original map, set in-object properties directly. 16487 // If we still have the original map, set in-object properties directly.
16486 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, Smi::kZero, 16488 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
16487 SKIP_WRITE_BARRIER); 16489 Smi::FromInt(0), SKIP_WRITE_BARRIER);
16488 } else { 16490 } else {
16489 // Map has changed, so use generic, but slower, method. 16491 // Map has changed, so use generic, but slower, method.
16490 RETURN_ON_EXCEPTION(isolate, JSReceiver::SetProperty( 16492 RETURN_ON_EXCEPTION(
16491 regexp, factory->last_index_string(), 16493 isolate,
16492 Handle<Smi>(Smi::kZero, isolate), STRICT), 16494 JSReceiver::SetProperty(regexp, factory->last_index_string(),
16493 JSRegExp); 16495 Handle<Smi>(Smi::FromInt(0), isolate), STRICT),
16496 JSRegExp);
16494 } 16497 }
16495 16498
16496 return regexp; 16499 return regexp;
16497 } 16500 }
16498 16501
16499 16502
16500 // RegExpKey carries the source and flags of a regular expression as key. 16503 // RegExpKey carries the source and flags of a regular expression as key.
16501 class RegExpKey : public HashTableKey { 16504 class RegExpKey : public HashTableKey {
16502 public: 16505 public:
16503 RegExpKey(Handle<String> string, JSRegExp::Flags flags) 16506 RegExpKey(Handle<String> string, JSRegExp::Flags flags)
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
17199 17202
17200 // Collect holes at the end, undefined before that and the rest at the 17203 // Collect holes at the end, undefined before that and the rest at the
17201 // start, and return the number of non-hole, non-undefined values. 17204 // start, and return the number of non-hole, non-undefined values.
17202 17205
17203 Handle<FixedArrayBase> elements_base(object->elements()); 17206 Handle<FixedArrayBase> elements_base(object->elements());
17204 uint32_t elements_length = static_cast<uint32_t>(elements_base->length()); 17207 uint32_t elements_length = static_cast<uint32_t>(elements_base->length());
17205 if (limit > elements_length) { 17208 if (limit > elements_length) {
17206 limit = elements_length; 17209 limit = elements_length;
17207 } 17210 }
17208 if (limit == 0) { 17211 if (limit == 0) {
17209 return handle(Smi::kZero, isolate); 17212 return handle(Smi::FromInt(0), isolate);
17210 } 17213 }
17211 17214
17212 uint32_t result = 0; 17215 uint32_t result = 0;
17213 if (elements_base->map() == isolate->heap()->fixed_double_array_map()) { 17216 if (elements_base->map() == isolate->heap()->fixed_double_array_map()) {
17214 FixedDoubleArray* elements = FixedDoubleArray::cast(*elements_base); 17217 FixedDoubleArray* elements = FixedDoubleArray::cast(*elements_base);
17215 // Split elements into defined and the_hole, in that order. 17218 // Split elements into defined and the_hole, in that order.
17216 unsigned int holes = limit; 17219 unsigned int holes = limit;
17217 // Assume most arrays contain no holes and undefined values, so minimize the 17220 // Assume most arrays contain no holes and undefined values, so minimize the
17218 // number of stores of non-undefined, non-the-hole values. 17221 // number of stores of non-undefined, non-the-hole values.
17219 for (unsigned int i = 0; i < holes; i++) { 17222 for (unsigned int i = 0; i < holes; i++) {
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
18622 18625
18623 template<class Derived, class TableType> 18626 template<class Derived, class TableType>
18624 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) { 18627 Smi* OrderedHashTableIterator<Derived, TableType>::Next(JSArray* value_array) {
18625 DisallowHeapAllocation no_allocation; 18628 DisallowHeapAllocation no_allocation;
18626 if (HasMore()) { 18629 if (HasMore()) {
18627 FixedArray* array = FixedArray::cast(value_array->elements()); 18630 FixedArray* array = FixedArray::cast(value_array->elements());
18628 static_cast<Derived*>(this)->PopulateValueArray(array); 18631 static_cast<Derived*>(this)->PopulateValueArray(array);
18629 MoveNext(); 18632 MoveNext();
18630 return Smi::cast(kind()); 18633 return Smi::cast(kind());
18631 } 18634 }
18632 return Smi::kZero; 18635 return Smi::FromInt(0);
18633 } 18636 }
18634 18637
18635 18638
18636 template Smi* 18639 template Smi*
18637 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::Next( 18640 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::Next(
18638 JSArray* value_array); 18641 JSArray* value_array);
18639 18642
18640 template bool 18643 template bool
18641 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::HasMore(); 18644 OrderedHashTableIterator<JSSetIterator, OrderedHashSet>::HasMore();
18642 18645
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
19228 } 19231 }
19229 19232
19230 Handle<String> src = handle(String::cast(the_script->source()), isolate); 19233 Handle<String> src = handle(String::cast(the_script->source()), isolate);
19231 return isolate->factory()->NewSubString(src, info.line_start, info.line_end); 19234 return isolate->factory()->NewSubString(src, info.line_start, info.line_end);
19232 } 19235 }
19233 19236
19234 void JSArrayBuffer::Neuter() { 19237 void JSArrayBuffer::Neuter() {
19235 CHECK(is_neuterable()); 19238 CHECK(is_neuterable());
19236 CHECK(is_external()); 19239 CHECK(is_external());
19237 set_backing_store(NULL); 19240 set_backing_store(NULL);
19238 set_byte_length(Smi::kZero); 19241 set_byte_length(Smi::FromInt(0));
19239 set_was_neutered(true); 19242 set_was_neutered(true);
19240 } 19243 }
19241 19244
19242 19245
19243 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, 19246 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate,
19244 bool is_external, void* data, size_t allocated_length, 19247 bool is_external, void* data, size_t allocated_length,
19245 SharedFlag shared) { 19248 SharedFlag shared) {
19246 DCHECK(array_buffer->GetInternalFieldCount() == 19249 DCHECK(array_buffer->GetInternalFieldCount() ==
19247 v8::ArrayBuffer::kInternalFieldCount); 19250 v8::ArrayBuffer::kInternalFieldCount);
19248 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { 19251 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
19249 array_buffer->SetInternalField(i, Smi::kZero); 19252 array_buffer->SetInternalField(i, Smi::FromInt(0));
19250 } 19253 }
19251 array_buffer->set_bit_field(0); 19254 array_buffer->set_bit_field(0);
19252 array_buffer->set_is_external(is_external); 19255 array_buffer->set_is_external(is_external);
19253 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); 19256 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared);
19254 array_buffer->set_is_shared(shared == SharedFlag::kShared); 19257 array_buffer->set_is_shared(shared == SharedFlag::kShared);
19255 19258
19256 Handle<Object> byte_length = 19259 Handle<Object> byte_length =
19257 isolate->factory()->NewNumberFromSize(allocated_length); 19260 isolate->factory()->NewNumberFromSize(allocated_length);
19258 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); 19261 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
19259 array_buffer->set_byte_length(*byte_length); 19262 array_buffer->set_byte_length(*byte_length);
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
19882 } 19885 }
19883 19886
19884 // Evaluation of module body. 19887 // Evaluation of module body.
19885 Handle<JSFunction> resume( 19888 Handle<JSFunction> resume(
19886 isolate->native_context()->generator_next_internal(), isolate); 19889 isolate->native_context()->generator_next_internal(), isolate);
19887 return Execution::Call(isolate, resume, generator, 0, nullptr); 19890 return Execution::Call(isolate, resume, generator, 0, nullptr);
19888 } 19891 }
19889 19892
19890 } // namespace internal 19893 } // namespace internal
19891 } // namespace v8 19894 } // 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