| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5657 isolate->heap()->external_string_table()->AddString(*external); | 5657 isolate->heap()->external_string_table()->AddString(*external); |
| 5658 } | 5658 } |
| 5659 return result; | 5659 return result; |
| 5660 } | 5660 } |
| 5661 | 5661 |
| 5662 | 5662 |
| 5663 bool v8::String::CanMakeExternal() { | 5663 bool v8::String::CanMakeExternal() { |
| 5664 if (!internal::FLAG_clever_optimizations) return false; | 5664 if (!internal::FLAG_clever_optimizations) return false; |
| 5665 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5665 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5666 i::Isolate* isolate = obj->GetIsolate(); | 5666 i::Isolate* isolate = obj->GetIsolate(); |
| 5667 |
| 5668 // TODO(yangguo): Externalizing sliced/cons strings allocates. |
| 5669 // This rule can be removed when all code that can |
| 5670 // trigger an access check is handlified and therefore GC safe. |
| 5671 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; |
| 5672 |
| 5667 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5673 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
| 5668 int size = obj->Size(); // Byte size of the original string. | 5674 int size = obj->Size(); // Byte size of the original string. |
| 5669 if (size < i::ExternalString::kShortSize) return false; | 5675 if (size < i::ExternalString::kShortSize) return false; |
| 5670 i::StringShape shape(*obj); | 5676 i::StringShape shape(*obj); |
| 5671 return !shape.IsExternal(); | 5677 return !shape.IsExternal(); |
| 5672 } | 5678 } |
| 5673 | 5679 |
| 5674 | 5680 |
| 5675 Local<v8::Object> v8::Object::New() { | 5681 Local<v8::Object> v8::Object::New() { |
| 5676 i::Isolate* isolate = i::Isolate::Current(); | 5682 i::Isolate* isolate = i::Isolate::Current(); |
| (...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7566 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7572 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7567 Address callback_address = | 7573 Address callback_address = |
| 7568 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7574 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7569 VMState<EXTERNAL> state(isolate); | 7575 VMState<EXTERNAL> state(isolate); |
| 7570 ExternalCallbackScope call_scope(isolate, callback_address); | 7576 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7571 callback(info); | 7577 callback(info); |
| 7572 } | 7578 } |
| 7573 | 7579 |
| 7574 | 7580 |
| 7575 } } // namespace v8::internal | 7581 } } // namespace v8::internal |
| OLD | NEW |