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

Side by Side Diff: src/runtime.cc

Issue 409007: Some optimizations for packer.js. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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
« src/objects-inl.h ('K') | « src/objects-inl.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 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 2349
2350 return Smi::FromInt(str1_length - str2_length); 2350 return Smi::FromInt(str1_length - str2_length);
2351 } 2351 }
2352 2352
2353 2353
2354 static Object* Runtime_SubString(Arguments args) { 2354 static Object* Runtime_SubString(Arguments args) {
2355 NoHandleAllocation ha; 2355 NoHandleAllocation ha;
2356 ASSERT(args.length() == 3); 2356 ASSERT(args.length() == 3);
2357 2357
2358 CONVERT_CHECKED(String, value, args[0]); 2358 CONVERT_CHECKED(String, value, args[0]);
2359 CONVERT_DOUBLE_CHECKED(from_number, args[1]); 2359 Object* from = args[1];
2360 CONVERT_DOUBLE_CHECKED(to_number, args[2]); 2360 Object* to = args[2];
2361 if (from->IsSmi() && to->IsSmi()) {
Søren Thygesen Gjesse 2009/11/19 21:42:57 Maybe add a comment to this fast case.
2362 int start = Smi::cast(from)->value();
2363 int end = Smi::cast(to)->value();
2361 2364
Søren Thygesen Gjesse 2009/11/19 21:42:57 Please move the declaration of start and end befor
2362 int start = FastD2I(from_number); 2365 RUNTIME_ASSERT(end >= start);
2363 int end = FastD2I(to_number); 2366 RUNTIME_ASSERT(start >= 0);
2367 RUNTIME_ASSERT(end <= value->length());
2368 return value->SubString(start, end);
2369 } else {
2370 CONVERT_DOUBLE_CHECKED(from_number, from);
2371 CONVERT_DOUBLE_CHECKED(to_number, to);
2364 2372
2365 RUNTIME_ASSERT(end >= start); 2373 int start = FastD2I(from_number);
2366 RUNTIME_ASSERT(start >= 0); 2374 int end = FastD2I(to_number);
2367 RUNTIME_ASSERT(end <= value->length()); 2375
2368 return value->SubString(start, end); 2376 RUNTIME_ASSERT(end >= start);
2377 RUNTIME_ASSERT(start >= 0);
2378 RUNTIME_ASSERT(end <= value->length());
2379 return value->SubString(start, end);
2380 }
2369 } 2381 }
2370 2382
2371 2383
2372 static Object* Runtime_StringMatch(Arguments args) { 2384 static Object* Runtime_StringMatch(Arguments args) {
2373 ASSERT_EQ(3, args.length()); 2385 ASSERT_EQ(3, args.length());
2374 2386
2375 CONVERT_ARG_CHECKED(String, subject, 0); 2387 CONVERT_ARG_CHECKED(String, subject, 0);
2376 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); 2388 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1);
2377 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2); 2389 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2);
2378 HandleScope handles; 2390 HandleScope handles;
(...skipping 5524 matching lines...) Expand 10 before | Expand all | Expand 10 after
7903 } else { 7915 } else {
7904 // Handle last resort GC and make sure to allow future allocations 7916 // Handle last resort GC and make sure to allow future allocations
7905 // to grow the heap without causing GCs (if possible). 7917 // to grow the heap without causing GCs (if possible).
7906 Counters::gc_last_resort_from_js.Increment(); 7918 Counters::gc_last_resort_from_js.Increment();
7907 Heap::CollectAllGarbage(false); 7919 Heap::CollectAllGarbage(false);
7908 } 7920 }
7909 } 7921 }
7910 7922
7911 7923
7912 } } // namespace v8::internal 7924 } } // namespace v8::internal
OLDNEW
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698