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