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

Side by Side Diff: src/runtime.cc

Issue 141323007: Fix inconsistencies wrt whitespaces. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: new license header Created 6 years, 10 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/jsregexp.cc ('k') | src/scanner.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 6523 matching lines...) Expand 10 before | Expand all | Expand 10 after
6534 args, isolate, isolate->runtime_state()->to_lower_mapping()); 6534 args, isolate, isolate->runtime_state()->to_lower_mapping());
6535 } 6535 }
6536 6536
6537 6537
6538 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) { 6538 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) {
6539 return ConvertCase( 6539 return ConvertCase(
6540 args, isolate, isolate->runtime_state()->to_upper_mapping()); 6540 args, isolate, isolate->runtime_state()->to_upper_mapping());
6541 } 6541 }
6542 6542
6543 6543
6544 static inline bool IsTrimWhiteSpace(unibrow::uchar c) {
6545 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff;
6546 }
6547
6548
6549 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { 6544 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
6550 HandleScope scope(isolate); 6545 HandleScope scope(isolate);
6551 ASSERT(args.length() == 3); 6546 ASSERT(args.length() == 3);
6552 6547
6553 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); 6548 CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
6554 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); 6549 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1);
6555 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); 6550 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2);
6556 6551
6557 string = FlattenGetString(string); 6552 string = FlattenGetString(string);
6558 int length = string->length(); 6553 int length = string->length();
6559 6554
6560 int left = 0; 6555 int left = 0;
6556 UnicodeCache* unicode_cache = isolate->unicode_cache();
6561 if (trimLeft) { 6557 if (trimLeft) {
6562 while (left < length && IsTrimWhiteSpace(string->Get(left))) { 6558 while (left < length &&
6559 unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(left))) {
6563 left++; 6560 left++;
6564 } 6561 }
6565 } 6562 }
6566 6563
6567 int right = length; 6564 int right = length;
6568 if (trimRight) { 6565 if (trimRight) {
6569 while (right > left && IsTrimWhiteSpace(string->Get(right - 1))) { 6566 while (right > left &&
6567 unicode_cache->IsWhiteSpaceOrLineTerminator(
6568 string->Get(right - 1))) {
6570 right--; 6569 right--;
6571 } 6570 }
6572 } 6571 }
6573 6572
6574 return *isolate->factory()->NewSubString(string, left, right); 6573 return *isolate->factory()->NewSubString(string, left, right);
6575 } 6574 }
6576 6575
6577 6576
6578 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { 6577 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
6579 HandleScope handle_scope(isolate); 6578 HandleScope handle_scope(isolate);
(...skipping 8285 matching lines...) Expand 10 before | Expand all | Expand 10 after
14865 // Handle last resort GC and make sure to allow future allocations 14864 // Handle last resort GC and make sure to allow future allocations
14866 // to grow the heap without causing GCs (if possible). 14865 // to grow the heap without causing GCs (if possible).
14867 isolate->counters()->gc_last_resort_from_js()->Increment(); 14866 isolate->counters()->gc_last_resort_from_js()->Increment();
14868 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14867 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14869 "Runtime::PerformGC"); 14868 "Runtime::PerformGC");
14870 } 14869 }
14871 } 14870 }
14872 14871
14873 14872
14874 } } // namespace v8::internal 14873 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698