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 } | 5538 } |
5539 return result; | 5539 return result; |
5540 } | 5540 } |
5541 | 5541 |
5542 | 5542 |
5543 bool v8::String::CanMakeExternal() { | 5543 bool v8::String::CanMakeExternal() { |
5544 if (!internal::FLAG_clever_optimizations) return false; | 5544 if (!internal::FLAG_clever_optimizations) return false; |
5545 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5545 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5546 i::Isolate* isolate = obj->GetIsolate(); | 5546 i::Isolate* isolate = obj->GetIsolate(); |
5547 | 5547 |
| 5548 // TODO(yangguo): Externalizing sliced/cons strings allocates. |
| 5549 // This rule can be removed when all code that can |
| 5550 // trigger an access check is handlified and therefore GC safe. |
| 5551 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; |
| 5552 |
5548 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5553 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
5549 int size = obj->Size(); // Byte size of the original string. | 5554 int size = obj->Size(); // Byte size of the original string. |
5550 if (size < i::ExternalString::kShortSize) return false; | 5555 if (size < i::ExternalString::kShortSize) return false; |
5551 i::StringShape shape(*obj); | 5556 i::StringShape shape(*obj); |
5552 return !shape.IsExternal(); | 5557 return !shape.IsExternal(); |
5553 } | 5558 } |
5554 | 5559 |
5555 | 5560 |
5556 Local<v8::Object> v8::Object::New(Isolate* isolate) { | 5561 Local<v8::Object> v8::Object::New(Isolate* isolate) { |
5557 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5562 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7633 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7638 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7634 Address callback_address = | 7639 Address callback_address = |
7635 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7640 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7636 VMState<EXTERNAL> state(isolate); | 7641 VMState<EXTERNAL> state(isolate); |
7637 ExternalCallbackScope call_scope(isolate, callback_address); | 7642 ExternalCallbackScope call_scope(isolate, callback_address); |
7638 callback(info); | 7643 callback(info); |
7639 } | 7644 } |
7640 | 7645 |
7641 | 7646 |
7642 } } // namespace v8::internal | 7647 } } // namespace v8::internal |
OLD | NEW |