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

Side by Side Diff: src/runtime.cc

Issue 50004: * Made Date string parser reuse the same output array each time. (Closed)
Patch Set: Created 11 years, 9 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
« no previous file with comments | « src/runtime.h ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 4462 matching lines...) Expand 10 before | Expand all | Expand 10 after
4473 // the number in a Date object representing a particular instant in 4473 // the number in a Date object representing a particular instant in
4474 // time is milliseconds. Therefore, we floor the result of getting 4474 // time is milliseconds. Therefore, we floor the result of getting
4475 // the OS time. 4475 // the OS time.
4476 double millis = floor(OS::TimeCurrentMillis()); 4476 double millis = floor(OS::TimeCurrentMillis());
4477 return Heap::NumberFromDouble(millis); 4477 return Heap::NumberFromDouble(millis);
4478 } 4478 }
4479 4479
4480 4480
4481 static Object* Runtime_DateParseString(Arguments args) { 4481 static Object* Runtime_DateParseString(Arguments args) {
4482 HandleScope scope; 4482 HandleScope scope;
4483 ASSERT(args.length() == 1); 4483 ASSERT(args.length() == 2);
4484 4484
4485 CONVERT_CHECKED(String, string_object, args[0]); 4485 CONVERT_ARG_CHECKED(String, str, 0);
4486 FlattenString(str);
4486 4487
4487 Handle<String> str(string_object); 4488 CONVERT_ARG_CHECKED(JSArray, output, 1);
4488 FlattenString(str); 4489 RUNTIME_ASSERT(output->HasFastElements());
4489 Handle<FixedArray> output = Factory::NewFixedArray(DateParser::OUTPUT_SIZE); 4490
4491 AssertNoAllocation no_allocation;
4492
4493 FixedArray* output_array = output->elements();
4494 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
4490 bool result; 4495 bool result;
4491 { 4496 if (StringShape(*str).IsAsciiRepresentation()) {
4492 AssertNoAllocation no_allocation; 4497 result = DateParser::Parse(str->ToAsciiVector(), output_array);
4493 if (StringShape(*str).IsAsciiRepresentation()) { 4498 } else {
4494 result = DateParser::Parse(str->ToAsciiVector(), *output); 4499 ASSERT(StringShape(*str).IsTwoByteRepresentation());
4495 } else { 4500 result = DateParser::Parse(str->ToUC16Vector(), output_array);
4496 ASSERT(StringShape(*str).IsTwoByteRepresentation());
4497 result = DateParser::Parse(str->ToUC16Vector(), *output);
4498 }
4499 } 4501 }
4502
4500 if (result) { 4503 if (result) {
4501 return *Factory::NewJSArrayWithElements(output); 4504 return *output;
4502 } else { 4505 } else {
4503 return *Factory::null_value(); 4506 return Heap::null_value();
4504 } 4507 }
4505 } 4508 }
4506 4509
4507 4510
4508 static Object* Runtime_DateLocalTimezone(Arguments args) { 4511 static Object* Runtime_DateLocalTimezone(Arguments args) {
4509 NoHandleAllocation ha; 4512 NoHandleAllocation ha;
4510 ASSERT(args.length() == 1); 4513 ASSERT(args.length() == 1);
4511 4514
4512 CONVERT_DOUBLE_CHECKED(x, args[0]); 4515 CONVERT_DOUBLE_CHECKED(x, args[0]);
4513 char* zone = OS::LocalTimezone(x); 4516 char* zone = OS::LocalTimezone(x);
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
6724 } else { 6727 } else {
6725 // Handle last resort GC and make sure to allow future allocations 6728 // Handle last resort GC and make sure to allow future allocations
6726 // to grow the heap without causing GCs (if possible). 6729 // to grow the heap without causing GCs (if possible).
6727 Counters::gc_last_resort_from_js.Increment(); 6730 Counters::gc_last_resort_from_js.Increment();
6728 Heap::CollectAllGarbage(); 6731 Heap::CollectAllGarbage();
6729 } 6732 }
6730 } 6733 }
6731 6734
6732 6735
6733 } } // namespace v8::internal 6736 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698