OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 5527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5538 length); | 5538 length); |
5539 } | 5539 } |
5540 | 5540 |
5541 | 5541 |
5542 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { | 5542 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { |
5543 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5543 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
5544 i::Isolate* isolate = left_string->GetIsolate(); | 5544 i::Isolate* isolate = left_string->GetIsolate(); |
5545 LOG_API(isolate, "String::New(char)"); | 5545 LOG_API(isolate, "String::New(char)"); |
5546 ENTER_V8(isolate); | 5546 ENTER_V8(isolate); |
5547 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5547 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
5548 // We do not expect this to fail. Change this if it does. | 5548 // If we are steering towards a range error, do not wait for the error to be |
| 5549 // thrown, and return the null handle instead. |
| 5550 if (left_string->length() + right_string->length() > i::String::kMaxLength) { |
| 5551 return Local<String>(); |
| 5552 } |
5549 i::Handle<i::String> result = isolate->factory()->NewConsString( | 5553 i::Handle<i::String> result = isolate->factory()->NewConsString( |
5550 left_string, right_string).ToHandleChecked(); | 5554 left_string, right_string).ToHandleChecked(); |
5551 return Utils::ToLocal(result); | 5555 return Utils::ToLocal(result); |
5552 } | 5556 } |
5553 | 5557 |
5554 | 5558 |
5555 static i::MaybeHandle<i::String> NewExternalStringHandle( | 5559 static i::MaybeHandle<i::String> NewExternalStringHandle( |
5556 i::Isolate* isolate, v8::String::ExternalStringResource* resource) { | 5560 i::Isolate* isolate, v8::String::ExternalStringResource* resource) { |
5557 return isolate->factory()->NewExternalStringFromTwoByte(resource); | 5561 return isolate->factory()->NewExternalStringFromTwoByte(resource); |
5558 } | 5562 } |
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7771 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7775 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7772 Address callback_address = | 7776 Address callback_address = |
7773 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7777 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7774 VMState<EXTERNAL> state(isolate); | 7778 VMState<EXTERNAL> state(isolate); |
7775 ExternalCallbackScope call_scope(isolate, callback_address); | 7779 ExternalCallbackScope call_scope(isolate, callback_address); |
7776 callback(info); | 7780 callback(info); |
7777 } | 7781 } |
7778 | 7782 |
7779 | 7783 |
7780 } } // namespace v8::internal | 7784 } } // namespace v8::internal |
OLD | NEW |