Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: src/api.cc

Issue 6716023: Remove TLS fetches in v8::String API implementation. (Closed)
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 ENTER_V8; 3907 ENTER_V8;
3908 if (length == -1) length = i::StrLength(data); 3908 if (length == -1) length = i::StrLength(data);
3909 i::Handle<i::String> result = 3909 i::Handle<i::String> result =
3910 isolate->factory()->NewStringFromUtf8( 3910 isolate->factory()->NewStringFromUtf8(
3911 i::Vector<const char>(data, length)); 3911 i::Vector<const char>(data, length));
3912 return Utils::ToLocal(result); 3912 return Utils::ToLocal(result);
3913 } 3913 }
3914 3914
3915 3915
3916 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { 3916 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
3917 i::Isolate* isolate = i::Isolate::Current(); 3917 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
3918 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 3918 i::Isolate* isolate = left_string->GetIsolate();
3919 LOG_API(isolate, "String::New(char)"); 3919 EnsureInitializedForIsolate(isolate, "v8::String::Concat()");
3920 LOG_API(isolate, "String::Concat()");
3920 ENTER_V8; 3921 ENTER_V8;
3921 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
3922 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 3922 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
3923 i::Handle<i::String> result = FACTORY->NewConsString(left_string, 3923 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
3924 right_string); 3924 right_string);
3925 return Utils::ToLocal(result); 3925 return Utils::ToLocal(result);
3926 } 3926 }
3927 3927
3928 3928
3929 Local<String> v8::String::NewUndetectable(const char* data, int length) { 3929 Local<String> v8::String::NewUndetectable(const char* data, int length) {
3930 i::Isolate* isolate = i::Isolate::Current(); 3930 i::Isolate* isolate = i::Isolate::Current();
3931 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()"); 3931 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
3932 LOG_API(isolate, "String::NewUndetectable(char)"); 3932 LOG_API(isolate, "String::NewUndetectable(char)");
3933 ENTER_V8; 3933 ENTER_V8;
3934 if (length == -1) length = i::StrLength(data); 3934 if (length == -1) length = i::StrLength(data);
3935 i::Handle<i::String> result = 3935 i::Handle<i::String> result =
3936 FACTORY->NewStringFromUtf8(i::Vector<const char>(data, length)); 3936 isolate->factory()->NewStringFromUtf8(
3937 i::Vector<const char>(data, length));
3937 result->MarkAsUndetectable(); 3938 result->MarkAsUndetectable();
3938 return Utils::ToLocal(result); 3939 return Utils::ToLocal(result);
3939 } 3940 }
3940 3941
3941 3942
3942 static int TwoByteStringLength(const uint16_t* data) { 3943 static int TwoByteStringLength(const uint16_t* data) {
3943 int length = 0; 3944 int length = 0;
3944 while (data[length] != '\0') length++; 3945 while (data[length] != '\0') length++;
3945 return length; 3946 return length;
3946 } 3947 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3996 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); 3997 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
3997 LOG_API(isolate, "String::NewExternal"); 3998 LOG_API(isolate, "String::NewExternal");
3998 ENTER_V8; 3999 ENTER_V8;
3999 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); 4000 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource);
4000 isolate->heap()->external_string_table()->AddString(*result); 4001 isolate->heap()->external_string_table()->AddString(*result);
4001 return Utils::ToLocal(result); 4002 return Utils::ToLocal(result);
4002 } 4003 }
4003 4004
4004 4005
4005 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 4006 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
4006 i::Isolate* isolate = i::Isolate::Current(); 4007 i::Handle<i::String> obj = Utils::OpenHandle(this);
4008 i::Isolate* isolate = obj->GetIsolate();
4007 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4009 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4008 if (this->IsExternal()) return false; // Already an external string. 4010 if (this->IsExternal()) return false; // Already an external string.
4009 ENTER_V8; 4011 ENTER_V8;
4010 i::Handle<i::String> obj = Utils::OpenHandle(this);
4011 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4012 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4012 return false; 4013 return false;
4013 } 4014 }
4014 bool result = obj->MakeExternal(resource); 4015 bool result = obj->MakeExternal(resource);
4015 if (result && !obj->IsSymbol()) { 4016 if (result && !obj->IsSymbol()) {
4016 isolate->heap()->external_string_table()->AddString(*obj); 4017 isolate->heap()->external_string_table()->AddString(*obj);
4017 } 4018 }
4018 return result; 4019 return result;
4019 } 4020 }
4020 4021
4021 4022
4022 Local<String> v8::String::NewExternal( 4023 Local<String> v8::String::NewExternal(
4023 v8::String::ExternalAsciiStringResource* resource) { 4024 v8::String::ExternalAsciiStringResource* resource) {
4024 i::Isolate* isolate = i::Isolate::Current(); 4025 i::Isolate* isolate = i::Isolate::Current();
4025 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); 4026 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4026 LOG_API(isolate, "String::NewExternal"); 4027 LOG_API(isolate, "String::NewExternal");
4027 ENTER_V8; 4028 ENTER_V8;
4028 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); 4029 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource);
4029 isolate->heap()->external_string_table()->AddString(*result); 4030 isolate->heap()->external_string_table()->AddString(*result);
4030 return Utils::ToLocal(result); 4031 return Utils::ToLocal(result);
4031 } 4032 }
4032 4033
4033 4034
4034 bool v8::String::MakeExternal( 4035 bool v8::String::MakeExternal(
4035 v8::String::ExternalAsciiStringResource* resource) { 4036 v8::String::ExternalAsciiStringResource* resource) {
4036 i::Isolate* isolate = i::Isolate::Current(); 4037 i::Handle<i::String> obj = Utils::OpenHandle(this);
4038 i::Isolate* isolate = obj->GetIsolate();
4037 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4039 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4038 if (this->IsExternal()) return false; // Already an external string. 4040 if (this->IsExternal()) return false; // Already an external string.
4039 ENTER_V8; 4041 ENTER_V8;
4040 i::Handle<i::String> obj = Utils::OpenHandle(this);
4041 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4042 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4042 return false; 4043 return false;
4043 } 4044 }
4044 bool result = obj->MakeExternal(resource); 4045 bool result = obj->MakeExternal(resource);
4045 if (result && !obj->IsSymbol()) { 4046 if (result && !obj->IsSymbol()) {
4046 isolate->heap()->external_string_table()->AddString(*obj); 4047 isolate->heap()->external_string_table()->AddString(*obj);
4047 } 4048 }
4048 return result; 4049 return result;
4049 } 4050 }
4050 4051
4051 4052
4052 bool v8::String::CanMakeExternal() { 4053 bool v8::String::CanMakeExternal() {
4053 i::Isolate* isolate = i::Isolate::Current(); 4054 i::Handle<i::String> obj = Utils::OpenHandle(this);
4055 i::Isolate* isolate = obj->GetIsolate();
4054 if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false; 4056 if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false;
4055 i::Handle<i::String> obj = Utils::OpenHandle(this);
4056 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4057 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4057 return false; 4058 return false;
4058 } 4059 }
4059 int size = obj->Size(); // Byte size of the original string. 4060 int size = obj->Size(); // Byte size of the original string.
4060 if (size < i::ExternalString::kSize) 4061 if (size < i::ExternalString::kSize)
4061 return false; 4062 return false;
4062 i::StringShape shape(*obj); 4063 i::StringShape shape(*obj);
4063 return !shape.IsExternal(); 4064 return !shape.IsExternal();
4064 } 4065 }
4065 4066
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
5608 5609
5609 5610
5610 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5611 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5611 HandleScopeImplementer* thread_local = 5612 HandleScopeImplementer* thread_local =
5612 reinterpret_cast<HandleScopeImplementer*>(storage); 5613 reinterpret_cast<HandleScopeImplementer*>(storage);
5613 thread_local->IterateThis(v); 5614 thread_local->IterateThis(v);
5614 return storage + ArchiveSpacePerThread(); 5615 return storage + ArchiveSpacePerThread();
5615 } 5616 }
5616 5617
5617 } } // namespace v8::internal 5618 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698