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

Side by Side Diff: src/objects.cc

Issue 7516: - Optimized copying of FixedArray. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // print that using vsnprintf (which may truncate but never allocate if 882 // print that using vsnprintf (which may truncate but never allocate if
883 // there is no more space in the buffer). 883 // there is no more space in the buffer).
884 EmbeddedVector<char, 100> buffer; 884 EmbeddedVector<char, 100> buffer;
885 OS::SNPrintF(buffer, "%.16g", Number()); 885 OS::SNPrintF(buffer, "%.16g", Number());
886 accumulator->Add("%s", buffer.start()); 886 accumulator->Add("%s", buffer.start());
887 } 887 }
888 888
889 889
890 String* JSObject::class_name() { 890 String* JSObject::class_name() {
891 if (IsJSFunction()) return Heap::function_class_symbol(); 891 if (IsJSFunction()) return Heap::function_class_symbol();
892 // If the constructor is not present "Object" is returned.
893 String* result = Heap::Object_symbol();
894 if (map()->constructor()->IsJSFunction()) { 892 if (map()->constructor()->IsJSFunction()) {
895 JSFunction* constructor = JSFunction::cast(map()->constructor()); 893 JSFunction* constructor = JSFunction::cast(map()->constructor());
896 return String::cast(constructor->shared()->instance_class_name()); 894 return String::cast(constructor->shared()->instance_class_name());
897 } 895 }
898 return result; 896 // If the constructor is not present, return "Object".
897 return Heap::Object_symbol();
899 } 898 }
900 899
901 900
902 void JSObject::JSObjectIterateBody(int object_size, ObjectVisitor* v) { 901 void JSObject::JSObjectIterateBody(int object_size, ObjectVisitor* v) {
903 // Iterate over all fields in the body. Assumes all are Object*. 902 // Iterate over all fields in the body. Assumes all are Object*.
904 IteratePointers(v, kPropertiesOffset, object_size); 903 IteratePointers(v, kPropertiesOffset, object_size);
905 } 904 }
906 905
907 906
908 Object* JSObject::Copy(PretenureFlag pretenure) { 907 Object* JSObject::Copy(PretenureFlag pretenure) {
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 if (!HasKey(this, other->get(y))) { 2530 if (!HasKey(this, other->get(y))) {
2532 result->set(len0 + index, other->get(y)); 2531 result->set(len0 + index, other->get(y));
2533 index++; 2532 index++;
2534 } 2533 }
2535 } 2534 }
2536 ASSERT(extra == index); 2535 ASSERT(extra == index);
2537 return result; 2536 return result;
2538 } 2537 }
2539 2538
2540 2539
2541 Object* FixedArray::Copy() {
2542 int len = length();
2543 if (len == 0) return this;
2544 Object* obj = Heap::AllocateFixedArray(len);
2545 if (obj->IsFailure()) return obj;
2546 FixedArray* result = FixedArray::cast(obj);
2547 WriteBarrierMode mode = result->GetWriteBarrierMode();
2548 // Copy the content
2549 for (int i = 0; i < len; i++) {
2550 result->set(i, get(i), mode);
2551 }
2552 result->set_map(map());
2553 return result;
2554 }
2555
2556 Object* FixedArray::CopySize(int new_length) { 2540 Object* FixedArray::CopySize(int new_length) {
2557 if (new_length == 0) return Heap::empty_fixed_array(); 2541 if (new_length == 0) return Heap::empty_fixed_array();
2558 Object* obj = Heap::AllocateFixedArray(new_length); 2542 Object* obj = Heap::AllocateFixedArray(new_length);
2559 if (obj->IsFailure()) return obj; 2543 if (obj->IsFailure()) return obj;
2560 FixedArray* result = FixedArray::cast(obj); 2544 FixedArray* result = FixedArray::cast(obj);
2561 WriteBarrierMode mode = result->GetWriteBarrierMode(); 2545 WriteBarrierMode mode = result->GetWriteBarrierMode();
2562 // Copy the content 2546 // Copy the content
2563 int len = length(); 2547 int len = length();
2564 if (new_length < len) len = new_length; 2548 if (new_length < len) len = new_length;
2565 for (int i = 0; i < len; i++) { 2549 for (int i = 0; i < len; i++) {
(...skipping 3858 matching lines...) Expand 10 before | Expand all | Expand 10 after
6424 // No break point. 6408 // No break point.
6425 if (break_point_objects()->IsUndefined()) return 0; 6409 if (break_point_objects()->IsUndefined()) return 0;
6426 // Single beak point. 6410 // Single beak point.
6427 if (!break_point_objects()->IsFixedArray()) return 1; 6411 if (!break_point_objects()->IsFixedArray()) return 1;
6428 // Multiple break points. 6412 // Multiple break points.
6429 return FixedArray::cast(break_point_objects())->length(); 6413 return FixedArray::cast(break_point_objects())->length();
6430 } 6414 }
6431 6415
6432 6416
6433 } } // namespace v8::internal 6417 } } // namespace v8::internal
OLDNEW
« src/heap.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