OLD | NEW |
---|---|
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 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2409 Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); | 2409 Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); |
2410 result->set_length(Smi::FromInt(matches)); | 2410 result->set_length(Smi::FromInt(matches)); |
2411 return *result; | 2411 return *result; |
2412 } | 2412 } |
2413 | 2413 |
2414 | 2414 |
2415 static Object* Runtime_NumberToRadixString(Arguments args) { | 2415 static Object* Runtime_NumberToRadixString(Arguments args) { |
2416 NoHandleAllocation ha; | 2416 NoHandleAllocation ha; |
2417 ASSERT(args.length() == 2); | 2417 ASSERT(args.length() == 2); |
2418 | 2418 |
2419 // Fast case where the result is a one char string. | |
Kasper Lund
2009/06/16 06:41:18
char -> character
| |
2420 if (args[0]->IsSmi() && args[1]->IsSmi()) { | |
2421 int value = Smi::cast(args[0])->value(); | |
2422 int radix = Smi::cast(args[1])->value(); | |
2423 if (value >= 0 && value < radix) { | |
2424 RUNTIME_ASSERT(radix <= 36); | |
2425 // Character array used for conversion. | |
2426 static const char chars[] = "0123456789abcdefghijklmnopqrstuvwxyz"; | |
Kasper Lund
2009/06/16 06:41:18
Should be something like kChars or kCharsMap, righ
| |
2427 return Heap::LookupSingleCharacterStringFromCode(chars[value]); | |
2428 } | |
2429 } | |
2430 | |
2431 // Slow case. | |
2419 CONVERT_DOUBLE_CHECKED(value, args[0]); | 2432 CONVERT_DOUBLE_CHECKED(value, args[0]); |
2420 if (isnan(value)) { | 2433 if (isnan(value)) { |
2421 return Heap::AllocateStringFromAscii(CStrVector("NaN")); | 2434 return Heap::AllocateStringFromAscii(CStrVector("NaN")); |
2422 } | 2435 } |
2423 if (isinf(value)) { | 2436 if (isinf(value)) { |
2424 if (value < 0) { | 2437 if (value < 0) { |
2425 return Heap::AllocateStringFromAscii(CStrVector("-Infinity")); | 2438 return Heap::AllocateStringFromAscii(CStrVector("-Infinity")); |
2426 } | 2439 } |
2427 return Heap::AllocateStringFromAscii(CStrVector("Infinity")); | 2440 return Heap::AllocateStringFromAscii(CStrVector("Infinity")); |
2428 } | 2441 } |
(...skipping 5026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7455 } else { | 7468 } else { |
7456 // Handle last resort GC and make sure to allow future allocations | 7469 // Handle last resort GC and make sure to allow future allocations |
7457 // to grow the heap without causing GCs (if possible). | 7470 // to grow the heap without causing GCs (if possible). |
7458 Counters::gc_last_resort_from_js.Increment(); | 7471 Counters::gc_last_resort_from_js.Increment(); |
7459 Heap::CollectAllGarbage(); | 7472 Heap::CollectAllGarbage(); |
7460 } | 7473 } |
7461 } | 7474 } |
7462 | 7475 |
7463 | 7476 |
7464 } } // namespace v8::internal | 7477 } } // namespace v8::internal |
OLD | NEW |