| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 static Object* Runtime_IsConstructCall(Arguments args) { | 282 static Object* Runtime_IsConstructCall(Arguments args) { |
| 283 NoHandleAllocation ha; | 283 NoHandleAllocation ha; |
| 284 ASSERT(args.length() == 0); | 284 ASSERT(args.length() == 0); |
| 285 JavaScriptFrameIterator it; | 285 JavaScriptFrameIterator it; |
| 286 return Heap::ToBoolean(it.frame()->IsConstructor()); | 286 return Heap::ToBoolean(it.frame()->IsConstructor()); |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 static Object* Runtime_RegExpCompile(Arguments args) { | 290 static Object* Runtime_RegExpCompile(Arguments args) { |
| 291 HandleScope scope; // create a new handle scope | 291 HandleScope scope; |
| 292 ASSERT(args.length() == 3); | 292 ASSERT(args.length() == 3); |
| 293 CONVERT_CHECKED(JSRegExp, raw_re, args[0]); | 293 CONVERT_CHECKED(JSRegExp, raw_re, args[0]); |
| 294 Handle<JSRegExp> re(raw_re); | 294 Handle<JSRegExp> re(raw_re); |
| 295 CONVERT_CHECKED(String, raw_pattern, args[1]); | 295 CONVERT_CHECKED(String, raw_pattern, args[1]); |
| 296 Handle<String> pattern(raw_pattern); | 296 Handle<String> pattern(raw_pattern); |
| 297 CONVERT_CHECKED(String, raw_flags, args[2]); | 297 CONVERT_CHECKED(String, raw_flags, args[2]); |
| 298 Handle<String> flags(raw_flags); | 298 Handle<String> flags(raw_flags); |
| 299 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 299 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); |
| 300 if (result.is_null()) return Failure::Exception(); | 300 if (result.is_null()) return Failure::Exception(); |
| 301 return *result; | 301 return *result; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 779 |
| 780 static Object* Runtime_RegExpExec(Arguments args) { | 780 static Object* Runtime_RegExpExec(Arguments args) { |
| 781 HandleScope scope; | 781 HandleScope scope; |
| 782 ASSERT(args.length() == 3); | 782 ASSERT(args.length() == 3); |
| 783 CONVERT_CHECKED(JSRegExp, raw_regexp, args[0]); | 783 CONVERT_CHECKED(JSRegExp, raw_regexp, args[0]); |
| 784 Handle<JSRegExp> regexp(raw_regexp); | 784 Handle<JSRegExp> regexp(raw_regexp); |
| 785 CONVERT_CHECKED(String, raw_subject, args[1]); | 785 CONVERT_CHECKED(String, raw_subject, args[1]); |
| 786 Handle<String> subject(raw_subject); | 786 Handle<String> subject(raw_subject); |
| 787 Handle<Object> index(args[2]); | 787 Handle<Object> index(args[2]); |
| 788 ASSERT(index->IsNumber()); | 788 ASSERT(index->IsNumber()); |
| 789 return *RegExpImpl::Exec(regexp, subject, index); | 789 Handle<Object> result = RegExpImpl::Exec(regexp, subject, index); |
| 790 if (result.is_null()) return Failure::Exception(); |
| 791 return *result; |
| 790 } | 792 } |
| 791 | 793 |
| 792 | 794 |
| 793 static Object* Runtime_RegExpExecGlobal(Arguments args) { | 795 static Object* Runtime_RegExpExecGlobal(Arguments args) { |
| 794 HandleScope scope; | 796 HandleScope scope; |
| 795 ASSERT(args.length() == 2); | 797 ASSERT(args.length() == 2); |
| 796 CONVERT_CHECKED(JSRegExp, raw_regexp, args[0]); | 798 CONVERT_CHECKED(JSRegExp, raw_regexp, args[0]); |
| 797 Handle<JSRegExp> regexp(raw_regexp); | 799 Handle<JSRegExp> regexp(raw_regexp); |
| 798 CONVERT_CHECKED(String, raw_subject, args[1]); | 800 CONVERT_CHECKED(String, raw_subject, args[1]); |
| 799 Handle<String> subject(raw_subject); | 801 Handle<String> subject(raw_subject); |
| 800 return *RegExpImpl::ExecGlobal(regexp, subject); | 802 Handle<Object> result = RegExpImpl::ExecGlobal(regexp, subject); |
| 803 if (result.is_null()) return Failure::Exception(); |
| 804 return *result; |
| 801 } | 805 } |
| 802 | 806 |
| 803 | 807 |
| 804 static Object* Runtime_MaterializeRegExpLiteral(Arguments args) { | 808 static Object* Runtime_MaterializeRegExpLiteral(Arguments args) { |
| 805 HandleScope scope; | 809 HandleScope scope; |
| 806 ASSERT(args.length() == 4); | 810 ASSERT(args.length() == 4); |
| 807 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 811 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
| 808 int index = Smi::cast(args[1])->value(); | 812 int index = Smi::cast(args[1])->value(); |
| 809 Handle<String> pattern = args.at<String>(2); | 813 Handle<String> pattern = args.at<String>(2); |
| 810 Handle<String> flags = args.at<String>(3); | 814 Handle<String> flags = args.at<String>(3); |
| (...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 : Heap::AllocateRawTwoByteString(length); | 2441 : Heap::AllocateRawTwoByteString(length); |
| 2438 if (o->IsFailure()) return o; | 2442 if (o->IsFailure()) return o; |
| 2439 String* result = String::cast(o); | 2443 String* result = String::cast(o); |
| 2440 StringShape result_shape(result); | 2444 StringShape result_shape(result); |
| 2441 bool has_changed_character = false; | 2445 bool has_changed_character = false; |
| 2442 | 2446 |
| 2443 // Convert all characters to upper case, assuming that they will fit | 2447 // Convert all characters to upper case, assuming that they will fit |
| 2444 // in the buffer | 2448 // in the buffer |
| 2445 Access<StringInputBuffer> buffer(&string_input_buffer); | 2449 Access<StringInputBuffer> buffer(&string_input_buffer); |
| 2446 buffer->Reset(s); | 2450 buffer->Reset(s); |
| 2447 unibrow::uchar chars[unibrow::kMaxCaseConvertedSize]; | 2451 unibrow::uchar chars[Converter::kMaxWidth]; |
| 2448 int i = 0; | 2452 int i = 0; |
| 2449 // We can assume that the string is not empty | 2453 // We can assume that the string is not empty |
| 2450 uc32 current = buffer->GetNext(); | 2454 uc32 current = buffer->GetNext(); |
| 2451 while (i < length) { | 2455 while (i < length) { |
| 2452 bool has_next = buffer->has_more(); | 2456 bool has_next = buffer->has_more(); |
| 2453 uc32 next = has_next ? buffer->GetNext() : 0; | 2457 uc32 next = has_next ? buffer->GetNext() : 0; |
| 2454 int char_length = mapping->get(current, next, chars); | 2458 int char_length = mapping->get(current, next, chars); |
| 2455 if (char_length == 0) { | 2459 if (char_length == 0) { |
| 2456 // The case conversion of this character is the character itself. | 2460 // The case conversion of this character is the character itself. |
| 2457 result->Set(result_shape, i, current); | 2461 result->Set(result_shape, i, current); |
| (...skipping 3414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5872 } else { | 5876 } else { |
| 5873 // Handle last resort GC and make sure to allow future allocations | 5877 // Handle last resort GC and make sure to allow future allocations |
| 5874 // to grow the heap without causing GCs (if possible). | 5878 // to grow the heap without causing GCs (if possible). |
| 5875 Counters::gc_last_resort_from_js.Increment(); | 5879 Counters::gc_last_resort_from_js.Increment(); |
| 5876 Heap::CollectAllGarbage(); | 5880 Heap::CollectAllGarbage(); |
| 5877 } | 5881 } |
| 5878 } | 5882 } |
| 5879 | 5883 |
| 5880 | 5884 |
| 5881 } } // namespace v8::internal | 5885 } } // namespace v8::internal |
| OLD | NEW |