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

Side by Side Diff: src/runtime.cc

Issue 7527001: Encapsulate element handling into a class keyed on ElementsKind (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge with tot Created 9 years, 4 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 9181 matching lines...) Expand 10 before | Expand all | Expand 10 after
9192 ArrayConcatVisitor* visitor) { 9192 ArrayConcatVisitor* visitor) {
9193 Handle<ExternalArrayClass> array( 9193 Handle<ExternalArrayClass> array(
9194 ExternalArrayClass::cast(receiver->elements())); 9194 ExternalArrayClass::cast(receiver->elements()));
9195 uint32_t len = static_cast<uint32_t>(array->length()); 9195 uint32_t len = static_cast<uint32_t>(array->length());
9196 9196
9197 ASSERT(visitor != NULL); 9197 ASSERT(visitor != NULL);
9198 if (elements_are_ints) { 9198 if (elements_are_ints) {
9199 if (elements_are_guaranteed_smis) { 9199 if (elements_are_guaranteed_smis) {
9200 for (uint32_t j = 0; j < len; j++) { 9200 for (uint32_t j = 0; j < len; j++) {
9201 HandleScope loop_scope; 9201 HandleScope loop_scope;
9202 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get(j)))); 9202 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))));
9203 visitor->visit(j, e); 9203 visitor->visit(j, e);
9204 } 9204 }
9205 } else { 9205 } else {
9206 for (uint32_t j = 0; j < len; j++) { 9206 for (uint32_t j = 0; j < len; j++) {
9207 HandleScope loop_scope; 9207 HandleScope loop_scope;
9208 int64_t val = static_cast<int64_t>(array->get(j)); 9208 int64_t val = static_cast<int64_t>(array->get_scalar(j));
9209 if (Smi::IsValid(static_cast<intptr_t>(val))) { 9209 if (Smi::IsValid(static_cast<intptr_t>(val))) {
9210 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); 9210 Handle<Smi> e(Smi::FromInt(static_cast<int>(val)));
9211 visitor->visit(j, e); 9211 visitor->visit(j, e);
9212 } else { 9212 } else {
9213 Handle<Object> e = 9213 Handle<Object> e =
9214 isolate->factory()->NewNumber(static_cast<ElementType>(val)); 9214 isolate->factory()->NewNumber(static_cast<ElementType>(val));
9215 visitor->visit(j, e); 9215 visitor->visit(j, e);
9216 } 9216 }
9217 } 9217 }
9218 } 9218 }
9219 } else { 9219 } else {
9220 for (uint32_t j = 0; j < len; j++) { 9220 for (uint32_t j = 0; j < len; j++) {
9221 HandleScope loop_scope(isolate); 9221 HandleScope loop_scope(isolate);
9222 Handle<Object> e = isolate->factory()->NewNumber(array->get(j)); 9222 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j));
9223 visitor->visit(j, e); 9223 visitor->visit(j, e);
9224 } 9224 }
9225 } 9225 }
9226 } 9226 }
9227 9227
9228 9228
9229 // Used for sorting indices in a List<uint32_t>. 9229 // Used for sorting indices in a List<uint32_t>.
9230 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { 9230 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) {
9231 uint32_t a = *ap; 9231 uint32_t a = *ap;
9232 uint32_t b = *bp; 9232 uint32_t b = *bp;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
9398 do { 9398 do {
9399 j++; 9399 j++;
9400 } while (j < n && indices[j] == index); 9400 } while (j < n && indices[j] == index);
9401 } 9401 }
9402 break; 9402 break;
9403 } 9403 }
9404 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { 9404 case JSObject::EXTERNAL_PIXEL_ELEMENTS: {
9405 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( 9405 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast(
9406 receiver->elements())); 9406 receiver->elements()));
9407 for (uint32_t j = 0; j < length; j++) { 9407 for (uint32_t j = 0; j < length; j++) {
9408 Handle<Smi> e(Smi::FromInt(pixels->get(j))); 9408 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j)));
9409 visitor->visit(j, e); 9409 visitor->visit(j, e);
9410 } 9410 }
9411 break; 9411 break;
9412 } 9412 }
9413 case JSObject::EXTERNAL_BYTE_ELEMENTS: { 9413 case JSObject::EXTERNAL_BYTE_ELEMENTS: {
9414 IterateExternalArrayElements<ExternalByteArray, int8_t>( 9414 IterateExternalArrayElements<ExternalByteArray, int8_t>(
9415 isolate, receiver, true, true, visitor); 9415 isolate, receiver, true, true, visitor);
9416 break; 9416 break;
9417 } 9417 }
9418 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { 9418 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
(...skipping 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after
12766 } else { 12766 } else {
12767 // Handle last resort GC and make sure to allow future allocations 12767 // Handle last resort GC and make sure to allow future allocations
12768 // to grow the heap without causing GCs (if possible). 12768 // to grow the heap without causing GCs (if possible).
12769 isolate->counters()->gc_last_resort_from_js()->Increment(); 12769 isolate->counters()->gc_last_resort_from_js()->Increment();
12770 isolate->heap()->CollectAllGarbage(false); 12770 isolate->heap()->CollectAllGarbage(false);
12771 } 12771 }
12772 } 12772 }
12773 12773
12774 12774
12775 } } // namespace v8::internal 12775 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « src/objects-printer.cc ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698