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

Side by Side Diff: src/runtime.cc

Issue 8409010: Optimize JS date implementation for smi-only arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove superfluous double-elements case Created 9 years, 1 month 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/date.js ('k') | no next file » | 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 7857 matching lines...) Expand 10 before | Expand all | Expand 10 after
7868 ASSERT(args.length() == 2); 7868 ASSERT(args.length() == 2);
7869 7869
7870 CONVERT_DOUBLE_ARG_CHECKED(t, 0); 7870 CONVERT_DOUBLE_ARG_CHECKED(t, 0);
7871 CONVERT_CHECKED(JSArray, res_array, args[1]); 7871 CONVERT_CHECKED(JSArray, res_array, args[1]);
7872 7872
7873 int year, month, day; 7873 int year, month, day;
7874 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); 7874 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day);
7875 7875
7876 FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements()); 7876 FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements());
7877 RUNTIME_ASSERT(elms_base->length() == 3); 7877 RUNTIME_ASSERT(elms_base->length() == 3);
7878 RUNTIME_ASSERT(res_array->GetElementsKind() <= FAST_DOUBLE_ELEMENTS); 7878 RUNTIME_ASSERT(res_array->HasFastTypeElements());
7879 7879
7880 if (res_array->HasFastDoubleElements()) { 7880 MaybeObject* maybe = res_array->EnsureWritableFastElements();
7881 FixedDoubleArray* elms = FixedDoubleArray::cast(res_array->elements()); 7881 if (maybe->IsFailure()) return maybe;
7882 elms->set(0, year); 7882 FixedArray* elms = FixedArray::cast(res_array->elements());
7883 elms->set(1, month); 7883 elms->set(0, Smi::FromInt(year));
7884 elms->set(2, day); 7884 elms->set(1, Smi::FromInt(month));
7885 } else { 7885 elms->set(2, Smi::FromInt(day));
7886 FixedArray* elms = FixedArray::cast(res_array->elements());
7887 elms->set(0, Smi::FromInt(year));
7888 elms->set(1, Smi::FromInt(month));
7889 elms->set(2, Smi::FromInt(day));
7890 }
7891 7886
7892 return isolate->heap()->undefined_value(); 7887 return isolate->heap()->undefined_value();
7893 } 7888 }
7894 7889
7895 7890
7896 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) { 7891 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) {
7897 HandleScope scope(isolate); 7892 HandleScope scope(isolate);
7898 ASSERT(args.length() == 3); 7893 ASSERT(args.length() == 3);
7899 7894
7900 Handle<JSFunction> callee = args.at<JSFunction>(0); 7895 Handle<JSFunction> callee = args.at<JSFunction>(0);
(...skipping 5584 matching lines...) Expand 10 before | Expand all | Expand 10 after
13485 } else { 13480 } else {
13486 // Handle last resort GC and make sure to allow future allocations 13481 // Handle last resort GC and make sure to allow future allocations
13487 // to grow the heap without causing GCs (if possible). 13482 // to grow the heap without causing GCs (if possible).
13488 isolate->counters()->gc_last_resort_from_js()->Increment(); 13483 isolate->counters()->gc_last_resort_from_js()->Increment();
13489 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13484 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13490 } 13485 }
13491 } 13486 }
13492 13487
13493 13488
13494 } } // namespace v8::internal 13489 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/date.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698