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

Side by Side Diff: src/runtime.cc

Issue 8002019: Add Crankshaft support for smi-only elements (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments, added tests Created 9 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
« no previous file with comments | « src/ic.cc ('k') | src/x64/lithium-codegen-x64.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 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 is_cow ? elements : isolate->factory()->CopyFixedArray(elements); 436 is_cow ? elements : isolate->factory()->CopyFixedArray(elements);
437 437
438 Handle<FixedArray> content = Handle<FixedArray>::cast(copied_elements); 438 Handle<FixedArray> content = Handle<FixedArray>::cast(copied_elements);
439 bool has_non_smi = false; 439 bool has_non_smi = false;
440 if (is_cow) { 440 if (is_cow) {
441 // Copy-on-write arrays must be shallow (and simple). 441 // Copy-on-write arrays must be shallow (and simple).
442 if (FLAG_smi_only_arrays) { 442 if (FLAG_smi_only_arrays) {
443 for (int i = 0; i < content->length(); i++) { 443 for (int i = 0; i < content->length(); i++) {
444 Object* current = content->get(i); 444 Object* current = content->get(i);
445 ASSERT(!current->IsFixedArray()); 445 ASSERT(!current->IsFixedArray());
446 if (!current->IsSmi()) { 446 if (!current->IsSmi() && !current->IsTheHole()) {
447 has_non_smi = true; 447 has_non_smi = true;
448 } 448 }
449 } 449 }
450 } else { 450 } else {
451 #if DEBUG 451 #if DEBUG
452 for (int i = 0; i < content->length(); i++) { 452 for (int i = 0; i < content->length(); i++) {
453 ASSERT(!content->get(i)->IsFixedArray()); 453 ASSERT(!content->get(i)->IsFixedArray());
454 } 454 }
455 #endif 455 #endif
456 } 456 }
457 } else { 457 } else {
458 for (int i = 0; i < content->length(); i++) { 458 for (int i = 0; i < content->length(); i++) {
459 Object* current = content->get(i); 459 Object* current = content->get(i);
460 if (current->IsFixedArray()) { 460 if (current->IsFixedArray()) {
461 // The value contains the constant_properties of a 461 // The value contains the constant_properties of a
462 // simple object or array literal. 462 // simple object or array literal.
463 Handle<FixedArray> fa(FixedArray::cast(content->get(i))); 463 Handle<FixedArray> fa(FixedArray::cast(content->get(i)));
464 Handle<Object> result = 464 Handle<Object> result =
465 CreateLiteralBoilerplate(isolate, literals, fa); 465 CreateLiteralBoilerplate(isolate, literals, fa);
466 if (result.is_null()) return result; 466 if (result.is_null()) return result;
467 content->set(i, *result); 467 content->set(i, *result);
468 has_non_smi = true; 468 has_non_smi = true;
469 } else { 469 } else {
470 if (!current->IsSmi()) { 470 if (!current->IsSmi() && !current->IsTheHole()) {
471 has_non_smi = true; 471 has_non_smi = true;
472 } 472 }
473 } 473 }
474 } 474 }
475 } 475 }
476 476
477 // Set the elements. 477 // Set the elements.
478 Handle<JSArray> js_object(Handle<JSArray>::cast(object)); 478 Handle<JSArray> js_object(Handle<JSArray>::cast(object));
479 isolate->factory()->SetContent(js_object, content); 479 isolate->factory()->SetContent(js_object, content);
480 480
(...skipping 7762 matching lines...) Expand 10 before | Expand all | Expand 10 after
8243 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8243 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8244 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); 8244 if (!function->IsOptimizable()) return isolate->heap()->undefined_value();
8245 function->MarkForLazyRecompilation(); 8245 function->MarkForLazyRecompilation();
8246 return isolate->heap()->undefined_value(); 8246 return isolate->heap()->undefined_value();
8247 } 8247 }
8248 8248
8249 8249
8250 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { 8250 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
8251 HandleScope scope(isolate); 8251 HandleScope scope(isolate);
8252 ASSERT(args.length() == 1); 8252 ASSERT(args.length() == 1);
8253 // The least significant bit (after untagging) indicates whether the
8254 // function is currently optimized, regardless of reason.
8253 if (!V8::UseCrankshaft()) { 8255 if (!V8::UseCrankshaft()) {
8254 return Smi::FromInt(4); // 4 == "never". 8256 return Smi::FromInt(4); // 4 == "never".
8255 } 8257 }
8256 if (FLAG_always_opt) { 8258 if (FLAG_always_opt) {
8257 return Smi::FromInt(3); // 3 == "always". 8259 return Smi::FromInt(3); // 3 == "always".
8258 } 8260 }
8259 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8261 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8260 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 8262 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
8261 : Smi::FromInt(2); // 2 == "no". 8263 : Smi::FromInt(2); // 2 == "no".
8262 } 8264 }
(...skipping 4943 matching lines...) Expand 10 before | Expand all | Expand 10 after
13206 } else { 13208 } else {
13207 // Handle last resort GC and make sure to allow future allocations 13209 // Handle last resort GC and make sure to allow future allocations
13208 // to grow the heap without causing GCs (if possible). 13210 // to grow the heap without causing GCs (if possible).
13209 isolate->counters()->gc_last_resort_from_js()->Increment(); 13211 isolate->counters()->gc_last_resort_from_js()->Increment();
13210 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13212 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13211 } 13213 }
13212 } 13214 }
13213 13215
13214 13216
13215 } } // namespace v8::internal 13217 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698