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

Side by Side Diff: src/objects.cc

Issue 256993003: Remove some remnants of MaybeObjects in objects.*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 isolate); 364 isolate);
365 } 365 }
366 } 366 }
367 UNREACHABLE(); 367 UNREACHABLE();
368 return isolate->factory()->undefined_value(); 368 return isolate->factory()->undefined_value();
369 } 369 }
370 370
371 371
372 Handle<FixedArray> JSObject::EnsureWritableFastElements( 372 Handle<FixedArray> JSObject::EnsureWritableFastElements(
373 Handle<JSObject> object) { 373 Handle<JSObject> object) {
374 CALL_HEAP_FUNCTION(object->GetIsolate(), 374 ASSERT(object->HasFastSmiOrObjectElements());
375 object->EnsureWritableFastElements(), 375 Isolate* isolate = object->GetIsolate();
376 FixedArray); 376 Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate);
377 if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems;
378 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap(
379 elems, isolate->factory()->fixed_array_map());
380 object->set_elements(*writable_elems);
381 isolate->counters()->cow_arrays_converted()->Increment();
382 return writable_elems;
377 } 383 }
378 384
379 385
380 MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object, 386 MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object,
381 Handle<Object> receiver, 387 Handle<Object> receiver,
382 Handle<Object> structure, 388 Handle<Object> structure,
383 Handle<Name> name) { 389 Handle<Name> name) {
384 Isolate* isolate = name->GetIsolate(); 390 Isolate* isolate = name->GetIsolate();
385 // To accommodate both the old and the new api we switch on the 391 // To accommodate both the old and the new api we switch on the
386 // data structure used to store the callbacks. Eventually foreign 392 // data structure used to store the callbacks. Eventually foreign
(...skipping 8021 matching lines...) Expand 10 before | Expand all | Expand 10 after
8408 for (int i = 0; i < result->length(); i++) { 8414 for (int i = 0; i < result->length(); i++) {
8409 Object* current = result->get(i); 8415 Object* current = result->get(i);
8410 ASSERT(current->IsNumber() || current->IsName()); 8416 ASSERT(current->IsNumber() || current->IsName());
8411 } 8417 }
8412 } 8418 }
8413 #endif 8419 #endif
8414 return result; 8420 return result;
8415 } 8421 }
8416 8422
8417 8423
8418 MaybeObject* FixedArray::CopySize(int new_length, PretenureFlag pretenure) {
8419 Heap* heap = GetHeap();
8420 if (new_length == 0) return heap->empty_fixed_array();
8421 Object* obj;
8422 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length, pretenure);
8423 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
8424 }
8425 FixedArray* result = FixedArray::cast(obj);
8426 // Copy the content
8427 DisallowHeapAllocation no_gc;
8428 int len = length();
8429 if (new_length < len) len = new_length;
8430 // We are taking the map from the old fixed array so the map is sure to
8431 // be an immortal immutable object.
8432 result->set_map_no_write_barrier(map());
8433 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
8434 for (int i = 0; i < len; i++) {
8435 result->set(i, get(i), mode);
8436 }
8437 return result;
8438 }
8439
8440
8441 Handle<FixedArray> FixedArray::CopySize( 8424 Handle<FixedArray> FixedArray::CopySize(
8442 Handle<FixedArray> array, int new_length, PretenureFlag pretenure) { 8425 Handle<FixedArray> array, int new_length, PretenureFlag pretenure) {
8443 Isolate* isolate = array->GetIsolate(); 8426 Isolate* isolate = array->GetIsolate();
8444 CALL_HEAP_FUNCTION(isolate, 8427 if (new_length == 0) return isolate->factory()->empty_fixed_array();
8445 array->CopySize(new_length, pretenure), 8428 Handle<FixedArray> result =
8446 FixedArray); 8429 isolate->factory()->NewFixedArray(new_length, pretenure);
8430 // Copy the content
8431 DisallowHeapAllocation no_gc;
8432 int len = array->length();
8433 if (new_length < len) len = new_length;
8434 // We are taking the map from the old fixed array so the map is sure to
8435 // be an immortal immutable object.
8436 result->set_map_no_write_barrier(array->map());
8437 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
Hannes Payer (out of office) 2014/04/28 15:25:24 OMG, I just looked at the GetWriteBarrierMode. Ano
8438 for (int i = 0; i < len; i++) {
8439 result->set(i, array->get(i), mode);
8440 }
8441 return result;
8447 } 8442 }
8448 8443
8449 8444
8450 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { 8445 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) {
8451 DisallowHeapAllocation no_gc; 8446 DisallowHeapAllocation no_gc;
8452 WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc); 8447 WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc);
8453 for (int index = 0; index < len; index++) { 8448 for (int index = 0; index < len; index++) {
8454 dest->set(dest_pos+index, get(pos+index), mode); 8449 dest->set(dest_pos+index, get(pos+index), mode);
8455 } 8450 }
8456 } 8451 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
8588 return copy; 8583 return copy;
8589 } 8584 }
8590 8585
8591 8586
8592 Object* AccessorPair::GetComponent(AccessorComponent component) { 8587 Object* AccessorPair::GetComponent(AccessorComponent component) {
8593 Object* accessor = get(component); 8588 Object* accessor = get(component);
8594 return accessor->IsTheHole() ? GetHeap()->undefined_value() : accessor; 8589 return accessor->IsTheHole() ? GetHeap()->undefined_value() : accessor;
8595 } 8590 }
8596 8591
8597 8592
8598 MaybeObject* DeoptimizationInputData::Allocate(Isolate* isolate, 8593 Handle<DeoptimizationInputData> DeoptimizationInputData::New(
8599 int deopt_entry_count, 8594 Isolate* isolate,
8600 PretenureFlag pretenure) { 8595 int deopt_entry_count,
8596 PretenureFlag pretenure) {
8601 ASSERT(deopt_entry_count > 0); 8597 ASSERT(deopt_entry_count > 0);
8602 return isolate->heap()->AllocateFixedArray(LengthFor(deopt_entry_count), 8598 return Handle<DeoptimizationInputData>::cast(
8603 pretenure); 8599 isolate->factory()->NewFixedArray(
8600 LengthFor(deopt_entry_count), pretenure));
8604 } 8601 }
8605 8602
8606 8603
8607 MaybeObject* DeoptimizationOutputData::Allocate(Isolate* isolate, 8604 Handle<DeoptimizationOutputData> DeoptimizationOutputData::New(
8608 int number_of_deopt_points, 8605 Isolate* isolate,
8609 PretenureFlag pretenure) { 8606 int number_of_deopt_points,
8610 if (number_of_deopt_points == 0) return isolate->heap()->empty_fixed_array(); 8607 PretenureFlag pretenure) {
8611 return isolate->heap()->AllocateFixedArray( 8608 Handle<FixedArray> result;
8612 LengthOfFixedArray(number_of_deopt_points), pretenure); 8609 if (number_of_deopt_points == 0) {
8610 result = isolate->factory()->empty_fixed_array();
8611 } else {
8612 result = isolate->factory()->NewFixedArray(
8613 LengthOfFixedArray(number_of_deopt_points), pretenure);
8614 }
8615 return Handle<DeoptimizationOutputData>::cast(result);
8613 } 8616 }
8614 8617
8615 8618
8616 #ifdef DEBUG 8619 #ifdef DEBUG
8617 bool DescriptorArray::IsEqualTo(DescriptorArray* other) { 8620 bool DescriptorArray::IsEqualTo(DescriptorArray* other) {
8618 if (IsEmpty()) return other->IsEmpty(); 8621 if (IsEmpty()) return other->IsEmpty();
8619 if (other->IsEmpty()) return false; 8622 if (other->IsEmpty()) return false;
8620 if (length() != other->length()) return false; 8623 if (length() != other->length()) return false;
8621 for (int i = 0; i < length(); ++i) { 8624 for (int i = 0; i < length(); ++i) {
8622 if (get(i) != other->get(i)) return false; 8625 if (get(i) != other->get(i)) return false;
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
10047 // No optimized code map. 10050 // No optimized code map.
10048 ASSERT_EQ(0, Smi::cast(*value)->value()); 10051 ASSERT_EQ(0, Smi::cast(*value)->value());
10049 // Create 3 entries per context {context, code, literals}. 10052 // Create 3 entries per context {context, code, literals}.
10050 new_code_map = isolate->factory()->NewFixedArray(kInitialLength); 10053 new_code_map = isolate->factory()->NewFixedArray(kInitialLength);
10051 old_length = kEntriesStart; 10054 old_length = kEntriesStart;
10052 } else { 10055 } else {
10053 // Copy old map and append one new entry. 10056 // Copy old map and append one new entry.
10054 Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value); 10057 Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value);
10055 ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*native_context, osr_ast_id)); 10058 ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*native_context, osr_ast_id));
10056 old_length = old_code_map->length(); 10059 old_length = old_code_map->length();
10057 new_code_map = isolate->factory()->CopySizeFixedArray( 10060 new_code_map = FixedArray::CopySize(
10058 old_code_map, old_length + kEntryLength); 10061 old_code_map, old_length + kEntryLength);
10059 // Zap the old map for the sake of the heap verifier. 10062 // Zap the old map for the sake of the heap verifier.
10060 if (Heap::ShouldZapGarbage()) { 10063 if (Heap::ShouldZapGarbage()) {
10061 Object** data = old_code_map->data_start(); 10064 Object** data = old_code_map->data_start();
10062 MemsetPointer(data, isolate->heap()->the_hole_value(), old_length); 10065 MemsetPointer(data, isolate->heap()->the_hole_value(), old_length);
10063 } 10066 }
10064 } 10067 }
10065 new_code_map->set(old_length + kContextOffset, *native_context); 10068 new_code_map->set(old_length + kContextOffset, *native_context);
10066 new_code_map->set(old_length + kCachedCodeOffset, *code); 10069 new_code_map->set(old_length + kCachedCodeOffset, *code);
10067 new_code_map->set(old_length + kLiteralsOffset, *literals); 10070 new_code_map->set(old_length + kLiteralsOffset, *literals);
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
12098 const int header = kProtoTransitionHeaderSize; 12101 const int header = kProtoTransitionHeaderSize;
12099 12102
12100 Handle<FixedArray> cache(map->GetPrototypeTransitions()); 12103 Handle<FixedArray> cache(map->GetPrototypeTransitions());
12101 int capacity = (cache->length() - header) / step; 12104 int capacity = (cache->length() - header) / step;
12102 int transitions = map->NumberOfProtoTransitions() + 1; 12105 int transitions = map->NumberOfProtoTransitions() + 1;
12103 12106
12104 if (transitions > capacity) { 12107 if (transitions > capacity) {
12105 if (capacity > kMaxCachedPrototypeTransitions) return map; 12108 if (capacity > kMaxCachedPrototypeTransitions) return map;
12106 12109
12107 // Grow array by factor 2 over and above what we need. 12110 // Grow array by factor 2 over and above what we need.
12108 Factory* factory = map->GetIsolate()->factory(); 12111 cache = FixedArray::CopySize(cache, transitions * 2 * step + header);
12109 cache = factory->CopySizeFixedArray(cache, transitions * 2 * step + header);
12110 12112
12111 SetPrototypeTransitions(map, cache); 12113 SetPrototypeTransitions(map, cache);
12112 } 12114 }
12113 12115
12114 // Reload number of transitions as GC might shrink them. 12116 // Reload number of transitions as GC might shrink them.
12115 int last = map->NumberOfProtoTransitions(); 12117 int last = map->NumberOfProtoTransitions();
12116 int entry = header + last * step; 12118 int entry = header + last * step;
12117 12119
12118 cache->set(entry + kProtoTransitionPrototypeOffset, *prototype); 12120 cache->set(entry + kProtoTransitionPrototypeOffset, *prototype);
12119 cache->set(entry + kProtoTransitionMapOffset, *target_map); 12121 cache->set(entry + kProtoTransitionMapOffset, *target_map);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
12215 Handle<Object> object) { 12217 Handle<Object> object) {
12216 GroupStartIndexes starts(*entries); 12218 GroupStartIndexes starts(*entries);
12217 int start = starts.at(group); 12219 int start = starts.at(group);
12218 int end = starts.at(group + 1); 12220 int end = starts.at(group + 1);
12219 int number_of_entries = starts.number_of_entries(); 12221 int number_of_entries = starts.number_of_entries();
12220 // Check for existing entry to avoid duplicates. 12222 // Check for existing entry to avoid duplicates.
12221 for (int i = start; i < end; i++) { 12223 for (int i = start; i < end; i++) {
12222 if (entries->object_at(i) == *object) return entries; 12224 if (entries->object_at(i) == *object) return entries;
12223 } 12225 }
12224 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { 12226 if (entries->length() < kCodesStartIndex + number_of_entries + 1) {
12225 Factory* factory = entries->GetIsolate()->factory();
12226 int capacity = kCodesStartIndex + number_of_entries + 1; 12227 int capacity = kCodesStartIndex + number_of_entries + 1;
12227 if (capacity > 5) capacity = capacity * 5 / 4; 12228 if (capacity > 5) capacity = capacity * 5 / 4;
12228 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( 12229 Handle<DependentCode> new_entries = Handle<DependentCode>::cast(
12229 factory->CopySizeFixedArray(entries, capacity, TENURED)); 12230 FixedArray::CopySize(entries, capacity, TENURED));
12230 // The number of codes can change after GC. 12231 // The number of codes can change after GC.
12231 starts.Recompute(*entries); 12232 starts.Recompute(*entries);
12232 start = starts.at(group); 12233 start = starts.at(group);
12233 end = starts.at(group + 1); 12234 end = starts.at(group + 1);
12234 number_of_entries = starts.number_of_entries(); 12235 number_of_entries = starts.number_of_entries();
12235 for (int i = 0; i < number_of_entries; i++) { 12236 for (int i = 0; i < number_of_entries; i++) {
12236 entries->clear_at(i); 12237 entries->clear_at(i);
12237 } 12238 }
12238 // If the old fixed array was empty, we need to reset counters of the 12239 // If the old fixed array was empty, we need to reset counters of the
12239 // new array. 12240 // new array.
(...skipping 5083 matching lines...) Expand 10 before | Expand all | Expand 10 after
17323 #define ERROR_MESSAGES_TEXTS(C, T) T, 17324 #define ERROR_MESSAGES_TEXTS(C, T) T,
17324 static const char* error_messages_[] = { 17325 static const char* error_messages_[] = {
17325 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17326 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17326 }; 17327 };
17327 #undef ERROR_MESSAGES_TEXTS 17328 #undef ERROR_MESSAGES_TEXTS
17328 return error_messages_[reason]; 17329 return error_messages_[reason];
17329 } 17330 }
17330 17331
17331 17332
17332 } } // namespace v8::internal 17333 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698