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