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

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: fix nits 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 9182 matching lines...) Expand 10 before | Expand all | Expand 10 after
9193 ArrayConcatVisitor* visitor) { 9193 ArrayConcatVisitor* visitor) {
9194 Handle<ExternalArrayClass> array( 9194 Handle<ExternalArrayClass> array(
9195 ExternalArrayClass::cast(receiver->elements())); 9195 ExternalArrayClass::cast(receiver->elements()));
9196 uint32_t len = static_cast<uint32_t>(array->length()); 9196 uint32_t len = static_cast<uint32_t>(array->length());
9197 9197
9198 ASSERT(visitor != NULL); 9198 ASSERT(visitor != NULL);
9199 if (elements_are_ints) { 9199 if (elements_are_ints) {
9200 if (elements_are_guaranteed_smis) { 9200 if (elements_are_guaranteed_smis) {
9201 for (uint32_t j = 0; j < len; j++) { 9201 for (uint32_t j = 0; j < len; j++) {
9202 HandleScope loop_scope; 9202 HandleScope loop_scope;
9203 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get(j)))); 9203 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))));
9204 visitor->visit(j, e); 9204 visitor->visit(j, e);
9205 } 9205 }
9206 } else { 9206 } else {
9207 for (uint32_t j = 0; j < len; j++) { 9207 for (uint32_t j = 0; j < len; j++) {
9208 HandleScope loop_scope; 9208 HandleScope loop_scope;
9209 int64_t val = static_cast<int64_t>(array->get(j)); 9209 int64_t val = static_cast<int64_t>(array->get_scalar(j));
9210 if (Smi::IsValid(static_cast<intptr_t>(val))) { 9210 if (Smi::IsValid(static_cast<intptr_t>(val))) {
9211 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); 9211 Handle<Smi> e(Smi::FromInt(static_cast<int>(val)));
9212 visitor->visit(j, e); 9212 visitor->visit(j, e);
9213 } else { 9213 } else {
9214 Handle<Object> e = 9214 Handle<Object> e =
9215 isolate->factory()->NewNumber(static_cast<ElementType>(val)); 9215 isolate->factory()->NewNumber(static_cast<ElementType>(val));
9216 visitor->visit(j, e); 9216 visitor->visit(j, e);
9217 } 9217 }
9218 } 9218 }
9219 } 9219 }
9220 } else { 9220 } else {
9221 for (uint32_t j = 0; j < len; j++) { 9221 for (uint32_t j = 0; j < len; j++) {
9222 HandleScope loop_scope(isolate); 9222 HandleScope loop_scope(isolate);
9223 Handle<Object> e = isolate->factory()->NewNumber(array->get(j)); 9223 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j));
9224 visitor->visit(j, e); 9224 visitor->visit(j, e);
9225 } 9225 }
9226 } 9226 }
9227 } 9227 }
9228 9228
9229 9229
9230 // Used for sorting indices in a List<uint32_t>. 9230 // Used for sorting indices in a List<uint32_t>.
9231 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { 9231 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) {
9232 uint32_t a = *ap; 9232 uint32_t a = *ap;
9233 uint32_t b = *bp; 9233 uint32_t b = *bp;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
9399 do { 9399 do {
9400 j++; 9400 j++;
9401 } while (j < n && indices[j] == index); 9401 } while (j < n && indices[j] == index);
9402 } 9402 }
9403 break; 9403 break;
9404 } 9404 }
9405 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { 9405 case JSObject::EXTERNAL_PIXEL_ELEMENTS: {
9406 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( 9406 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast(
9407 receiver->elements())); 9407 receiver->elements()));
9408 for (uint32_t j = 0; j < length; j++) { 9408 for (uint32_t j = 0; j < length; j++) {
9409 Handle<Smi> e(Smi::FromInt(pixels->get(j))); 9409 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j)));
9410 visitor->visit(j, e); 9410 visitor->visit(j, e);
9411 } 9411 }
9412 break; 9412 break;
9413 } 9413 }
9414 case JSObject::EXTERNAL_BYTE_ELEMENTS: { 9414 case JSObject::EXTERNAL_BYTE_ELEMENTS: {
9415 IterateExternalArrayElements<ExternalByteArray, int8_t>( 9415 IterateExternalArrayElements<ExternalByteArray, int8_t>(
9416 isolate, receiver, true, true, visitor); 9416 isolate, receiver, true, true, visitor);
9417 break; 9417 break;
9418 } 9418 }
9419 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { 9419 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
(...skipping 3343 matching lines...) Expand 10 before | Expand all | Expand 10 after
12763 } else { 12763 } else {
12764 // Handle last resort GC and make sure to allow future allocations 12764 // Handle last resort GC and make sure to allow future allocations
12765 // to grow the heap without causing GCs (if possible). 12765 // to grow the heap without causing GCs (if possible).
12766 isolate->counters()->gc_last_resort_from_js()->Increment(); 12766 isolate->counters()->gc_last_resort_from_js()->Increment();
12767 isolate->heap()->CollectAllGarbage(false); 12767 isolate->heap()->CollectAllGarbage(false);
12768 } 12768 }
12769 } 12769 }
12770 12770
12771 12771
12772 } } // namespace v8::internal 12772 } } // namespace v8::internal
OLDNEW
« src/objects-inl.h ('K') | « src/objects-printer.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698