From: mstarzinger@chromium.org Date: Tue, 4 Jun 2013 10:30:05 +0000 (+0000) Subject: Deprecate FACTORY helper macro. X-Git-Tag: upstream/4.7.83~14024 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8db2414f207e21a76981dd5e56b6c486c0e5a95;p=platform%2Fupstream%2Fv8.git Deprecate FACTORY helper macro. This removes the FACTORY helper macro to avoid accidental TLS access when using the factory. Most internal code has access to the Isolate by now whereas tests which are not performance critical still heavily use TLS access through explicit Isolate::Current() calls. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/16337005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14931 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/api.cc b/src/api.cc index 7645a3f7a..9556b69b9 100644 --- a/src/api.cc +++ b/src/api.cc @@ -886,7 +886,8 @@ void NeanderArray::add(i::Handle value) { int length = this->length(); int size = obj_.size(); if (length == size - 1) { - i::Handle new_elms = FACTORY->NewFixedArray(2 * size); + i::Factory* factory = i::Isolate::Current()->factory(); + i::Handle new_elms = factory->NewFixedArray(2 * size); for (int i = 0; i < length; i++) new_elms->set(i + 1, get(i)); obj_.value()->set_elements(*new_elms); @@ -3856,7 +3857,8 @@ v8::Local v8::Object::GetHiddenValue(v8::Handle key) { ENTER_V8(isolate); i::Handle self = Utils::OpenHandle(this); i::Handle key_obj = Utils::OpenHandle(*key); - i::Handle key_string = FACTORY->InternalizeString(key_obj); + i::Handle key_string = + isolate->factory()->InternalizeString(key_obj); i::Handle result(self->GetHiddenProperty(*key_string), isolate); if (result->IsUndefined()) return v8::Local(); return Utils::ToLocal(result); @@ -3870,7 +3872,8 @@ bool v8::Object::DeleteHiddenValue(v8::Handle key) { i::HandleScope scope(isolate); i::Handle self = Utils::OpenHandle(this); i::Handle key_obj = Utils::OpenHandle(*key); - i::Handle key_string = FACTORY->InternalizeString(key_obj); + i::Handle key_string = + isolate->factory()->InternalizeString(key_obj); self->DeleteHiddenProperty(*key_string); return true; } @@ -5897,13 +5900,14 @@ void v8::Date::DateTimeConfigurationChangeNotification() { static i::Handle RegExpFlagsToString(RegExp::Flags flags) { + i::Isolate* isolate = i::Isolate::Current(); uint8_t flags_buf[3]; int num_flags = 0; if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; ASSERT(num_flags <= static_cast(ARRAY_SIZE(flags_buf))); - return FACTORY->InternalizeOneByteString( + return isolate->factory()->InternalizeOneByteString( i::Vector(flags_buf, num_flags)); } diff --git a/src/api.h b/src/api.h index 3d7e3778e..3c141f709 100644 --- a/src/api.h +++ b/src/api.h @@ -126,8 +126,9 @@ template inline T ToCData(v8::internal::Object* obj) { template inline v8::internal::Handle FromCData(T obj) { + v8::internal::Isolate* isolate = v8::internal::Isolate::Current(); STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address)); - return FACTORY->NewForeign( + return isolate->factory()->NewForeign( reinterpret_cast(reinterpret_cast(obj))); } diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 08c366c92..036099499 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -658,7 +658,7 @@ static void EmitIdenticalObjectComparison(MacroAssembler* masm, __ cmp(r0, r1); __ b(ne, ¬_identical); - // Test for NaN. Sadly, we can't just compare to FACTORY->nan_value(), + // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), // so we do the second best thing - test it ourselves. // They are both equal and they are not both Smis so both of them are not // Smis. If it's not a heap number, then return equal. diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 2b0491493..b9322b858 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -3013,7 +3013,7 @@ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( // string "valueOf" the result is false. // The use of ip to store the valueOf string assumes that it is not otherwise // used in the loop below. - __ mov(ip, Operand(FACTORY->value_of_string())); + __ mov(ip, Operand(isolate()->factory()->value_of_string())); __ jmp(&entry); __ bind(&loop); __ ldr(r3, MemOperand(r4, 0)); diff --git a/src/arm/regexp-macro-assembler-arm.cc b/src/arm/regexp-macro-assembler-arm.cc index da7afee3f..42415027e 100644 --- a/src/arm/regexp-macro-assembler-arm.cc +++ b/src/arm/regexp-macro-assembler-arm.cc @@ -917,9 +917,8 @@ Handle RegExpMacroAssemblerARM::GetCode(Handle source) { CodeDesc code_desc; masm_->GetCode(&code_desc); - Handle code = FACTORY->NewCode(code_desc, - Code::ComputeFlags(Code::REGEXP), - masm_->CodeObject()); + Handle code = isolate()->factory()->NewCode( + code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject()); PROFILE(Isolate::Current(), RegExpCodeCreateEvent(*code, *source)); return Handle::cast(code); } diff --git a/src/ast.cc b/src/ast.cc index 60cc3cd32..8c0351c01 100644 --- a/src/ast.cc +++ b/src/ast.cc @@ -1184,6 +1184,7 @@ void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { Handle Literal::ToString() { if (handle_->IsString()) return Handle::cast(handle_); + Factory* factory = Isolate::Current()->factory(); ASSERT(handle_->IsNumber()); char arr[100]; Vector buffer(arr, ARRAY_SIZE(arr)); @@ -1195,7 +1196,7 @@ Handle Literal::ToString() { } else { str = DoubleToCString(handle_->Number(), buffer); } - return FACTORY->NewStringFromAscii(CStrVector(str)); + return factory->NewStringFromAscii(CStrVector(str)); } diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 9277719b0..fb89452bd 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2126,7 +2126,8 @@ void Genesis::InstallJSFunctionResultCaches() { #undef F ; - Handle caches = FACTORY->NewFixedArray(kNumberOfCaches, TENURED); + Handle caches = + factory()->NewFixedArray(kNumberOfCaches, TENURED); int index = 0; @@ -2145,7 +2146,7 @@ void Genesis::InstallJSFunctionResultCaches() { void Genesis::InitializeNormalizedMapCaches() { Handle array( - FACTORY->NewFixedArray(NormalizedMapCache::kEntries, TENURED)); + factory()->NewFixedArray(NormalizedMapCache::kEntries, TENURED)); native_context()->set_normalized_map_cache(NormalizedMapCache::cast(*array)); } @@ -2505,14 +2506,13 @@ void Genesis::TransferIndexedProperties(Handle from, // Cloning the elements array is sufficient. Handle from_elements = Handle(FixedArray::cast(from->elements())); - Handle to_elements = FACTORY->CopyFixedArray(from_elements); + Handle to_elements = factory()->CopyFixedArray(from_elements); to->set_elements(*to_elements); } void Genesis::TransferObject(Handle from, Handle to) { HandleScope outer(isolate()); - Factory* factory = isolate()->factory(); ASSERT(!from->IsJSArray()); ASSERT(!to->IsJSArray()); @@ -2522,7 +2522,7 @@ void Genesis::TransferObject(Handle from, Handle to) { // Transfer the prototype (new map is needed). Handle old_to_map = Handle(to->map()); - Handle new_to_map = factory->CopyMap(old_to_map); + Handle new_to_map = factory()->CopyMap(old_to_map); new_to_map->set_prototype(from->map()->prototype()); to->set_map(*new_to_map); } diff --git a/src/bootstrapper.h b/src/bootstrapper.h index 476ac12e1..309780039 100644 --- a/src/bootstrapper.h +++ b/src/bootstrapper.h @@ -65,13 +65,14 @@ class SourceCodeCache BASE_EMBEDDED { } void Add(Vector name, Handle shared) { - HandleScope scope(shared->GetIsolate()); + Isolate* isolate = shared->GetIsolate(); + Factory* factory = isolate->factory(); + HandleScope scope(isolate); int length = cache_->length(); - Handle new_array = - FACTORY->NewFixedArray(length + 2, TENURED); + Handle new_array = factory->NewFixedArray(length + 2, TENURED); cache_->CopyTo(0, *new_array, 0, cache_->length()); cache_ = *new_array; - Handle str = FACTORY->NewStringFromAscii(name, TENURED); + Handle str = factory->NewStringFromAscii(name, TENURED); cache_->set(length, *str); cache_->set(length + 1, *shared); Script::cast(shared->script())->set_type(Smi::FromInt(type_)); diff --git a/src/compiler.cc b/src/compiler.cc index 9983b3d98..e44cd414b 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -649,7 +649,7 @@ Handle Compiler::Compile(Handle source, // in that case too. // Create a script object describing the script to be compiled. - Handle