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

Side by Side Diff: src/runtime.cc

Issue 521041: Improve keyed loads on strings by using a new stub (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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/runtime.h ('k') | src/runtime.js » ('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 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 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 Object* flat = subject->TryFlatten(); 1377 Object* flat = subject->TryFlatten();
1378 if (flat->IsFailure()) return flat; 1378 if (flat->IsFailure()) return flat;
1379 subject = String::cast(flat); 1379 subject = String::cast(flat);
1380 if (i >= static_cast<uint32_t>(subject->length())) { 1380 if (i >= static_cast<uint32_t>(subject->length())) {
1381 return Heap::nan_value(); 1381 return Heap::nan_value();
1382 } 1382 }
1383 return Smi::FromInt(subject->Get(i)); 1383 return Smi::FromInt(subject->Get(i));
1384 } 1384 }
1385 1385
1386 1386
1387 static Object* CharFromCode(Object* char_code) {
1388 uint32_t code;
1389 if (Array::IndexFromObject(char_code, &code)) {
1390 if (code <= 0xffff) {
1391 return Heap::LookupSingleCharacterStringFromCode(code);
1392 }
1393 }
1394 return Heap::empty_string();
1395 }
1396
1397
1387 static Object* Runtime_StringCharCodeAt(Arguments args) { 1398 static Object* Runtime_StringCharCodeAt(Arguments args) {
1388 NoHandleAllocation ha; 1399 NoHandleAllocation ha;
1389 ASSERT(args.length() == 2); 1400 ASSERT(args.length() == 2);
1390 1401
1391 CONVERT_CHECKED(String, subject, args[0]); 1402 CONVERT_CHECKED(String, subject, args[0]);
1392 Object* index = args[1]; 1403 Object* index = args[1];
1393 return CharCodeAt(subject, index); 1404 return CharCodeAt(subject, index);
1394 } 1405 }
1395 1406
1396 1407
1408 static Object* Runtime_StringCharAt(Arguments args) {
1409 NoHandleAllocation ha;
1410 ASSERT(args.length() == 2);
1411 return CharFromCode(Runtime_StringCharCodeAt(args));
1412 }
1413
1414
1397 static Object* Runtime_CharFromCode(Arguments args) { 1415 static Object* Runtime_CharFromCode(Arguments args) {
1398 NoHandleAllocation ha; 1416 NoHandleAllocation ha;
1399 ASSERT(args.length() == 1); 1417 ASSERT(args.length() == 1);
1400 uint32_t code; 1418 return CharFromCode(args[0]);
1401 if (Array::IndexFromObject(args[0], &code)) {
1402 if (code <= 0xffff) {
1403 return Heap::LookupSingleCharacterStringFromCode(code);
1404 }
1405 }
1406 return Heap::empty_string();
1407 } 1419 }
1408 1420
1409 // Forward declarations. 1421 // Forward declarations.
1410 static const int kStringBuilderConcatHelperLengthBits = 11; 1422 static const int kStringBuilderConcatHelperLengthBits = 11;
1411 static const int kStringBuilderConcatHelperPositionBits = 19; 1423 static const int kStringBuilderConcatHelperPositionBits = 19;
1412 1424
1413 template <typename schar> 1425 template <typename schar>
1414 static inline void StringBuilderConcatHelper(String*, 1426 static inline void StringBuilderConcatHelper(String*,
1415 schar*, 1427 schar*,
1416 FixedArray*, 1428 FixedArray*,
(...skipping 6609 matching lines...) Expand 10 before | Expand all | Expand 10 after
8026 } else { 8038 } else {
8027 // Handle last resort GC and make sure to allow future allocations 8039 // Handle last resort GC and make sure to allow future allocations
8028 // to grow the heap without causing GCs (if possible). 8040 // to grow the heap without causing GCs (if possible).
8029 Counters::gc_last_resort_from_js.Increment(); 8041 Counters::gc_last_resort_from_js.Increment();
8030 Heap::CollectAllGarbage(false); 8042 Heap::CollectAllGarbage(false);
8031 } 8043 }
8032 } 8044 }
8033 8045
8034 8046
8035 } } // namespace v8::internal 8047 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698