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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 static Object* Runtime_GetTemplateField(Arguments args) { | 515 static Object* Runtime_GetTemplateField(Arguments args) { |
516 ASSERT(args.length() == 2); | 516 ASSERT(args.length() == 2); |
517 CONVERT_CHECKED(HeapObject, templ, args[0]); | 517 CONVERT_CHECKED(HeapObject, templ, args[0]); |
518 CONVERT_CHECKED(Smi, field, args[1]); | 518 CONVERT_CHECKED(Smi, field, args[1]); |
519 int index = field->value(); | 519 int index = field->value(); |
520 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 520 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
521 InstanceType type = templ->map()->instance_type(); | 521 InstanceType type = templ->map()->instance_type(); |
522 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 522 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
523 type == OBJECT_TEMPLATE_INFO_TYPE); | 523 type == OBJECT_TEMPLATE_INFO_TYPE); |
524 RUNTIME_ASSERT(offset > 0); | 524 RUNTIME_ASSERT(offset > 0); |
525 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 525 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
526 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 526 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
527 } else { | 527 } else { |
528 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 528 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
529 } | 529 } |
530 return *HeapObject::RawField(templ, offset); | 530 return *HeapObject::RawField(templ, offset); |
531 } | 531 } |
532 | 532 |
533 | 533 |
534 static Object* Runtime_DisableAccessChecks(Arguments args) { | 534 static Object* Runtime_DisableAccessChecks(Arguments args) { |
535 ASSERT(args.length() == 1); | 535 ASSERT(args.length() == 1); |
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 buffer->Reset(source); | 3245 buffer->Reset(source); |
3246 while (buffer->has_more()) { | 3246 while (buffer->has_more()) { |
3247 uint16_t character = buffer->GetNext(); | 3247 uint16_t character = buffer->GetNext(); |
3248 if (character >= 256) { | 3248 if (character >= 256) { |
3249 escaped_length += 6; | 3249 escaped_length += 6; |
3250 } else if (IsNotEscaped(character)) { | 3250 } else if (IsNotEscaped(character)) { |
3251 escaped_length++; | 3251 escaped_length++; |
3252 } else { | 3252 } else { |
3253 escaped_length += 3; | 3253 escaped_length += 3; |
3254 } | 3254 } |
3255 // We don't allow strings that are longer than Smi range. | 3255 // We don't allow strings that are longer than a maximal length. |
3256 if (!Smi::IsValid(escaped_length)) { | 3256 if (escaped_length > String::kMaxLength) { |
3257 Top::context()->mark_out_of_memory(); | 3257 Top::context()->mark_out_of_memory(); |
3258 return Failure::OutOfMemoryException(); | 3258 return Failure::OutOfMemoryException(); |
3259 } | 3259 } |
3260 } | 3260 } |
3261 } | 3261 } |
3262 // No length change implies no change. Return original string if no change. | 3262 // No length change implies no change. Return original string if no change. |
3263 if (escaped_length == length) { | 3263 if (escaped_length == length) { |
3264 return source; | 3264 return source; |
3265 } | 3265 } |
3266 Object* o = Heap::AllocateRawAsciiString(escaped_length); | 3266 Object* o = Heap::AllocateRawAsciiString(escaped_length); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3797 int len = Smi::cast(elt)->value(); | 3797 int len = Smi::cast(elt)->value(); |
3798 int pos = len >> 11; | 3798 int pos = len >> 11; |
3799 len &= 0x7ff; | 3799 len &= 0x7ff; |
3800 if (pos + len > special_length) { | 3800 if (pos + len > special_length) { |
3801 return Top::Throw(Heap::illegal_argument_symbol()); | 3801 return Top::Throw(Heap::illegal_argument_symbol()); |
3802 } | 3802 } |
3803 position += len; | 3803 position += len; |
3804 } else if (elt->IsString()) { | 3804 } else if (elt->IsString()) { |
3805 String* element = String::cast(elt); | 3805 String* element = String::cast(elt); |
3806 int element_length = element->length(); | 3806 int element_length = element->length(); |
3807 if (!Smi::IsValid(element_length + position)) { | |
3808 Top::context()->mark_out_of_memory(); | |
3809 return Failure::OutOfMemoryException(); | |
3810 } | |
3811 position += element_length; | 3807 position += element_length; |
3812 if (ascii && !element->IsAsciiRepresentation()) { | 3808 if (ascii && !element->IsAsciiRepresentation()) { |
3813 ascii = false; | 3809 ascii = false; |
3814 } | 3810 } |
3815 } else { | 3811 } else { |
3816 return Top::Throw(Heap::illegal_argument_symbol()); | 3812 return Top::Throw(Heap::illegal_argument_symbol()); |
3817 } | 3813 } |
| 3814 if (position > String::kMaxLength) { |
| 3815 Top::context()->mark_out_of_memory(); |
| 3816 return Failure::OutOfMemoryException(); |
| 3817 } |
3818 } | 3818 } |
3819 | 3819 |
3820 int length = position; | 3820 int length = position; |
3821 Object* object; | 3821 Object* object; |
3822 | 3822 |
3823 if (ascii) { | 3823 if (ascii) { |
3824 object = Heap::AllocateRawAsciiString(length); | 3824 object = Heap::AllocateRawAsciiString(length); |
3825 if (object->IsFailure()) return object; | 3825 if (object->IsFailure()) return object; |
3826 SeqAsciiString* answer = SeqAsciiString::cast(object); | 3826 SeqAsciiString* answer = SeqAsciiString::cast(object); |
3827 StringBuilderConcatHelper(special, | 3827 StringBuilderConcatHelper(special, |
(...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7722 } else { | 7722 } else { |
7723 // Handle last resort GC and make sure to allow future allocations | 7723 // Handle last resort GC and make sure to allow future allocations |
7724 // to grow the heap without causing GCs (if possible). | 7724 // to grow the heap without causing GCs (if possible). |
7725 Counters::gc_last_resort_from_js.Increment(); | 7725 Counters::gc_last_resort_from_js.Increment(); |
7726 Heap::CollectAllGarbage(false); | 7726 Heap::CollectAllGarbage(false); |
7727 } | 7727 } |
7728 } | 7728 } |
7729 | 7729 |
7730 | 7730 |
7731 } } // namespace v8::internal | 7731 } } // namespace v8::internal |
OLD | NEW |