int length = this->length();
int size = obj_.size();
if (length == size - 1) {
- i::Handle<i::FixedArray> new_elms = FACTORY->NewFixedArray(2 * size);
+ i::Factory* factory = i::Isolate::Current()->factory();
+ i::Handle<i::FixedArray> 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);
ENTER_V8(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
- i::Handle<i::String> key_string = FACTORY->InternalizeString(key_obj);
+ i::Handle<i::String> key_string =
+ isolate->factory()->InternalizeString(key_obj);
i::Handle<i::Object> result(self->GetHiddenProperty(*key_string), isolate);
if (result->IsUndefined()) return v8::Local<v8::Value>();
return Utils::ToLocal(result);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
- i::Handle<i::String> key_string = FACTORY->InternalizeString(key_obj);
+ i::Handle<i::String> key_string =
+ isolate->factory()->InternalizeString(key_obj);
self->DeleteHiddenProperty(*key_string);
return true;
}
static i::Handle<i::String> 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<int>(ARRAY_SIZE(flags_buf)));
- return FACTORY->InternalizeOneByteString(
+ return isolate->factory()->InternalizeOneByteString(
i::Vector<const uint8_t>(flags_buf, num_flags));
}
template <typename T>
inline v8::internal::Handle<v8::internal::Object> 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<v8::internal::Address>(reinterpret_cast<intptr_t>(obj)));
}
__ 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.
// 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));
CodeDesc code_desc;
masm_->GetCode(&code_desc);
- Handle<Code> code = FACTORY->NewCode(code_desc,
- Code::ComputeFlags(Code::REGEXP),
- masm_->CodeObject());
+ Handle<Code> code = isolate()->factory()->NewCode(
+ code_desc, Code::ComputeFlags(Code::REGEXP), masm_->CodeObject());
PROFILE(Isolate::Current(), RegExpCodeCreateEvent(*code, *source));
return Handle<HeapObject>::cast(code);
}
Handle<String> Literal::ToString() {
if (handle_->IsString()) return Handle<String>::cast(handle_);
+ Factory* factory = Isolate::Current()->factory();
ASSERT(handle_->IsNumber());
char arr[100];
Vector<char> buffer(arr, ARRAY_SIZE(arr));
} else {
str = DoubleToCString(handle_->Number(), buffer);
}
- return FACTORY->NewStringFromAscii(CStrVector(str));
+ return factory->NewStringFromAscii(CStrVector(str));
}
#undef F
;
- Handle<FixedArray> caches = FACTORY->NewFixedArray(kNumberOfCaches, TENURED);
+ Handle<FixedArray> caches =
+ factory()->NewFixedArray(kNumberOfCaches, TENURED);
int index = 0;
void Genesis::InitializeNormalizedMapCaches() {
Handle<FixedArray> array(
- FACTORY->NewFixedArray(NormalizedMapCache::kEntries, TENURED));
+ factory()->NewFixedArray(NormalizedMapCache::kEntries, TENURED));
native_context()->set_normalized_map_cache(NormalizedMapCache::cast(*array));
}
// Cloning the elements array is sufficient.
Handle<FixedArray> from_elements =
Handle<FixedArray>(FixedArray::cast(from->elements()));
- Handle<FixedArray> to_elements = FACTORY->CopyFixedArray(from_elements);
+ Handle<FixedArray> to_elements = factory()->CopyFixedArray(from_elements);
to->set_elements(*to_elements);
}
void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
HandleScope outer(isolate());
- Factory* factory = isolate()->factory();
ASSERT(!from->IsJSArray());
ASSERT(!to->IsJSArray());
// Transfer the prototype (new map is needed).
Handle<Map> old_to_map = Handle<Map>(to->map());
- Handle<Map> new_to_map = factory->CopyMap(old_to_map);
+ Handle<Map> new_to_map = factory()->CopyMap(old_to_map);
new_to_map->set_prototype(from->map()->prototype());
to->set_map(*new_to_map);
}
}
void Add(Vector<const char> name, Handle<SharedFunctionInfo> shared) {
- HandleScope scope(shared->GetIsolate());
+ Isolate* isolate = shared->GetIsolate();
+ Factory* factory = isolate->factory();
+ HandleScope scope(isolate);
int length = cache_->length();
- Handle<FixedArray> new_array =
- FACTORY->NewFixedArray(length + 2, TENURED);
+ Handle<FixedArray> new_array = factory->NewFixedArray(length + 2, TENURED);
cache_->CopyTo(0, *new_array, 0, cache_->length());
cache_ = *new_array;
- Handle<String> str = FACTORY->NewStringFromAscii(name, TENURED);
+ Handle<String> str = factory->NewStringFromAscii(name, TENURED);
cache_->set(length, *str);
cache_->set(length + 1, *shared);
Script::cast(shared->script())->set_type(Smi::FromInt(type_));
// in that case too.
// Create a script object describing the script to be compiled.
- Handle<Script> script = FACTORY->NewScript(source);
+ Handle<Script> script = isolate->factory()->NewScript(source);
if (natives == NATIVES_CODE) {
script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
}
info.SetLanguageMode(literal->scope()->language_mode());
Isolate* isolate = info.isolate();
+ Factory* factory = isolate->factory();
LiveEditFunctionTracker live_edit_tracker(isolate, literal);
// Determine if the function can be lazily compiled. This is necessary to
// allow some of our builtin JS files to be lazily compiled. These
// Create a shared function info object.
Handle<SharedFunctionInfo> result =
- FACTORY->NewSharedFunctionInfo(literal->name(),
+ factory->NewSharedFunctionInfo(literal->name(),
literal->materialized_literal_count(),
literal->is_generator(),
info.code(),
Context::Scope scope(context);
#ifndef V8_SHARED
+ i::Factory* factory = i::Isolate::Current()->factory();
i::JSArguments js_args = i::FLAG_js_arguments;
i::Handle<i::FixedArray> arguments_array =
- FACTORY->NewFixedArray(js_args.argc());
+ factory->NewFixedArray(js_args.argc());
for (int j = 0; j < js_args.argc(); j++) {
i::Handle<i::String> arg =
- FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j]));
+ factory->NewStringFromUtf8(i::CStrVector(js_args[j]));
arguments_array->set(j, *arg);
}
i::Handle<i::JSArray> arguments_jsarray =
- FACTORY->NewJSArrayWithElements(arguments_array);
+ factory->NewJSArrayWithElements(arguments_array);
context->Global()->Set(String::New("arguments"),
Utils::ToLocal(arguments_jsarray));
#endif // V8_SHARED
Handle<FixedArray> ScriptCache::GetScripts() {
- Handle<FixedArray> instances = FACTORY->NewFixedArray(occupancy());
+ Factory* factory = Isolate::Current()->factory();
+ Handle<FixedArray> instances = factory->NewFixedArray(occupancy());
int count = 0;
for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) {
ASSERT(entry->value != NULL);
MessageLocation computed_location;
isolate->ComputeLocation(&computed_location);
Handle<Object> message = MessageHandler::MakeMessageObject(
- "error_loading_debugger", &computed_location,
+ isolate, "error_loading_debugger", &computed_location,
Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>());
ASSERT(!isolate->has_pending_exception());
if (!exception.is_null()) {
// Ensures the debug information is present for shared.
bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
Handle<JSFunction> function) {
+ Isolate* isolate = shared->GetIsolate();
+
// Return if we already have the debug info for shared.
if (HasDebugInfo(shared)) {
ASSERT(shared->is_compiled());
}
// Create the debug info object.
- Handle<DebugInfo> debug_info = FACTORY->NewDebugInfo(shared);
+ Handle<DebugInfo> debug_info = isolate->factory()->NewDebugInfo(shared);
// Add debug info to the list.
DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
Handle<Object> Execution::NewDate(double time, bool* exc) {
- Handle<Object> time_obj = FACTORY->NewNumber(time);
+ Isolate* isolate = Isolate::Current();
+ Handle<Object> time_obj = isolate->factory()->NewNumber(time);
RETURN_NATIVE_CALL(create_date, { time_obj }, exc);
}
SeededNumberDictionary::cast(obj)->set_requires_slow_elements();
set_empty_slow_element_dictionary(SeededNumberDictionary::cast(obj));
- // Handling of script id generation is in FACTORY->NewScript.
+ // Handling of script id generation is in Factory::NewScript.
set_last_script_id(undefined_value());
// Initialize keyed lookup cache.
HConstant* c_right = HConstant::cast(right);
HConstant* c_left = HConstant::cast(left);
if (c_left->HasStringValue() && c_right->HasStringValue()) {
- return new(zone) HConstant(FACTORY->NewConsString(c_left->StringValue(),
+ Factory* factory = Isolate::Current()->factory();
+ return new(zone) HConstant(factory->NewConsString(c_left->StringValue(),
c_right->StringValue()),
Representation::Tagged());
}
Handle<Object> handle() {
if (handle_.is_null()) {
+ Factory* factory = Isolate::Current()->factory();
// Default arguments to is_not_in_new_space depend on this heap number
// to be tenured so that it's guaranteed not be be located in new space.
- handle_ = FACTORY->NewNumber(double_value_, TENURED);
+ handle_ = factory->NewNumber(double_value_, TENURED);
}
AllowDeferredHandleDereference smi_check;
ASSERT(has_int32_value_ || !handle_->IsSmi());
void ArgumentsAccessStub::GenerateNewNonStrictFast(MacroAssembler* masm) {
+ Isolate* isolate = masm->isolate();
+
// esp[0] : return address
// esp[4] : number of parameters (tagged)
// esp[8] : receiver displacement
__ j(zero, &skip_parameter_map);
__ mov(FieldOperand(edi, FixedArray::kMapOffset),
- Immediate(FACTORY->non_strict_arguments_elements_map()));
+ Immediate(isolate->factory()->non_strict_arguments_elements_map()));
__ lea(eax, Operand(ebx, reinterpret_cast<intptr_t>(Smi::FromInt(2))));
__ mov(FieldOperand(edi, FixedArray::kLengthOffset), eax);
__ mov(FieldOperand(edi, FixedArray::kHeaderSize + 0 * kPointerSize), esi);
__ mov(ebx, Immediate(Smi::FromInt(Context::MIN_CONTEXT_SLOTS)));
__ add(ebx, Operand(esp, 4 * kPointerSize));
__ sub(ebx, eax);
- __ mov(ecx, FACTORY->the_hole_value());
+ __ mov(ecx, isolate->factory()->the_hole_value());
__ mov(edx, edi);
__ lea(edi, Operand(edi, eax, times_2, kParameterMapHeaderSize));
// eax = loop variable (tagged)
// esp[16] = address of receiver argument
// Copy arguments header and remaining slots (if there are any).
__ mov(FieldOperand(edi, FixedArray::kMapOffset),
- Immediate(FACTORY->fixed_array_map()));
+ Immediate(isolate->factory()->fixed_array_map()));
__ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx);
Label arguments_loop, arguments_test;
void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
+ Isolate* isolate = masm->isolate();
+
// esp[0] : return address
// esp[4] : number of parameters
// esp[8] : receiver displacement
__ lea(edi, Operand(eax, Heap::kArgumentsObjectSizeStrict));
__ mov(FieldOperand(eax, JSObject::kElementsOffset), edi);
__ mov(FieldOperand(edi, FixedArray::kMapOffset),
- Immediate(FACTORY->fixed_array_map()));
+ Immediate(isolate->factory()->fixed_array_map()));
__ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx);
// Untag the length for the loop below.
// Check for fast case object. Return false for slow case objects.
__ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset));
__ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset));
- __ cmp(ecx, FACTORY->hash_table_map());
+ __ cmp(ecx, isolate()->factory()->hash_table_map());
__ j(equal, if_false);
// Look for valueOf string in the descriptor array, and indicate false if
__ jmp(&entry);
__ bind(&loop);
__ mov(edx, FieldOperand(ebx, 0));
- __ cmp(edx, FACTORY->value_of_string());
+ __ cmp(edx, isolate()->factory()->value_of_string());
__ j(equal, if_false);
__ add(ebx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize));
__ bind(&entry);
__ j(not_zero, miss);
__ mov(r0, FieldOperand(receiver, JSObject::kPropertiesOffset));
- __ CheckMap(r0, FACTORY->hash_table_map(), miss, DONT_DO_SMI_CHECK);
+ __ CheckMap(r0, masm->isolate()->factory()->hash_table_map(), miss,
+ DONT_DO_SMI_CHECK);
}
if (not_fast_array != NULL) {
// Check that the object is in fast mode and writable.
__ CheckMap(scratch,
- FACTORY->fixed_array_map(),
+ masm->isolate()->factory()->fixed_array_map(),
not_fast_array,
DONT_DO_SMI_CHECK);
} else {
// Fast case: Do the load.
STATIC_ASSERT((kPointerSize == 4) && (kSmiTagSize == 1) && (kSmiTag == 0));
__ mov(scratch, FieldOperand(scratch, key, times_2, FixedArray::kHeaderSize));
- __ cmp(scratch, Immediate(FACTORY->the_hole_value()));
+ __ cmp(scratch, Immediate(masm->isolate()->factory()->the_hole_value()));
// In case the loaded value is the_hole we have to consult GetProperty
// to ensure the prototype chain is searched.
__ j(equal, out_of_range);
// Check for heap-number
mov(map, FieldOperand(value, HeapObject::kMapOffset));
- cmp(map, FACTORY->heap_number_map());
+ cmp(map, isolate()->factory()->heap_number_map());
j(not_equal, ¬_heap_number, Label::kNear);
mov(length, Immediate(HeapNumber::kSize));
jmp(&is_data_object, Label::kNear);
}
}
Handle<Object> message_obj = MessageHandler::MakeMessageObject(
+ this,
"uncaught_exception",
location,
HandleVector<Object>(&exception_arg, 1),
// Temporary macros for accessing current isolate and its subobjects.
// They provide better readability, especially when used a lot in the code.
#define HEAP (v8::internal::Isolate::Current()->heap())
-#define FACTORY (v8::internal::Isolate::Current()->factory())
#define ISOLATE (v8::internal::Isolate::Current())
for (int i = j; i < kSize; i++) {
templ[i] = bit;
}
+ Factory* factory = Isolate::Current()->factory();
// TODO(erikcorry): Cache these.
- Handle<ByteArray> ba = FACTORY->NewByteArray(kSize, TENURED);
+ Handle<ByteArray> ba = factory->NewByteArray(kSize, TENURED);
for (int i = 0; i < kSize; i++) {
ba->set(i, templ[i]);
}
return true;
}
- Handle<ByteArray> boolean_skip_table =
- FACTORY->NewByteArray(kSize, TENURED);
+ Factory* factory = Isolate::Current()->factory();
+ Handle<ByteArray> boolean_skip_table = factory->NewByteArray(kSize, TENURED);
int skip_distance = GetSkipTable(
min_lookahead, max_lookahead, boolean_skip_table);
ASSERT(skip_distance != 0);
// Wraps any object into a OpaqueReference, that will hide the object
// from JavaScript.
static Handle<JSValue> WrapInJSValue(Handle<Object> object) {
- Handle<JSFunction> constructor =
- Isolate::Current()->opaque_reference_function();
+ Isolate* isolate = Isolate::Current();
+ Handle<JSFunction> constructor = isolate->opaque_reference_function();
Handle<JSValue> result =
- Handle<JSValue>::cast(FACTORY->NewJSObject(constructor));
+ Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor));
result->set_value(*object);
return result;
}
class JSArrayBasedStruct {
public:
static S Create() {
- Handle<JSArray> array = FACTORY->NewJSArray(S::kSize_);
+ Factory* factory = Isolate::Current()->factory();
+ Handle<JSArray> array = factory->NewJSArray(S::kSize_);
return S(array);
}
static S cast(Object* object) {
if (shared_info->debug_info()->IsDebugInfo()) {
Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info()));
Handle<Code> new_original_code =
- FACTORY->CopyCode(compile_info_wrapper.GetFunctionCode());
+ isolate->factory()->CopyCode(compile_info_wrapper.GetFunctionCode());
debug_info->set_original_code(*new_original_code);
}
static Handle<Code> PatchPositionsInCode(
Handle<Code> code,
Handle<JSArray> position_change_array) {
+ Isolate* isolate = code->GetIsolate();
RelocInfoBuffer buffer_writer(code->relocation_size(),
code->instruction_start());
// Relocation info section now has different size. We cannot simply
// rewrite it inside code object. Instead we have to create a new
// code object.
- Handle<Code> result(FACTORY->CopyCode(code, buffer));
+ Handle<Code> result(isolate->factory()->CopyCode(code, buffer));
return result;
}
}
static Handle<Script> CreateScriptCopy(Handle<Script> original) {
- Handle<String> original_source(String::cast(original->source()));
+ Isolate* isolate = original->GetIsolate();
- Handle<Script> copy = FACTORY->NewScript(original_source);
+ Handle<String> original_source(String::cast(original->source()));
+ Handle<Script> copy = isolate->factory()->NewScript(original_source);
copy->set_name(original->name());
copy->set_line_offset(original->line_offset());
if (error_message != NULL) {
// Add error message as an array extra element.
Vector<const char> vector_message(error_message, StrLength(error_message));
- Handle<String> str = FACTORY->NewStringFromAscii(vector_message);
+ Handle<String> str = isolate->factory()->NewStringFromAscii(vector_message);
SetElementNonStrict(result, len, str);
}
return result;
Handle<JSMessageObject> MessageHandler::MakeMessageObject(
+ Isolate* isolate,
const char* type,
MessageLocation* loc,
Vector< Handle<Object> > args,
Handle<String> stack_trace,
Handle<JSArray> stack_frames) {
- Handle<String> type_handle = FACTORY->InternalizeUtf8String(type);
+ Factory* factory = isolate->factory();
+ Handle<String> type_handle = factory->InternalizeUtf8String(type);
Handle<FixedArray> arguments_elements =
- FACTORY->NewFixedArray(args.length());
+ factory->NewFixedArray(args.length());
for (int i = 0; i < args.length(); i++) {
arguments_elements->set(i, *args[i]);
}
Handle<JSArray> arguments_handle =
- FACTORY->NewJSArrayWithElements(arguments_elements);
+ factory->NewJSArrayWithElements(arguments_elements);
int start = 0;
int end = 0;
- Handle<Object> script_handle = FACTORY->undefined_value();
+ Handle<Object> script_handle = factory->undefined_value();
if (loc) {
start = loc->start_pos();
end = loc->end_pos();
}
Handle<Object> stack_trace_handle = stack_trace.is_null()
- ? Handle<Object>::cast(FACTORY->undefined_value())
+ ? Handle<Object>::cast(factory->undefined_value())
: Handle<Object>::cast(stack_trace);
Handle<Object> stack_frames_handle = stack_frames.is_null()
- ? Handle<Object>::cast(FACTORY->undefined_value())
+ ? Handle<Object>::cast(factory->undefined_value())
: Handle<Object>::cast(stack_frames);
Handle<JSMessageObject> message =
- FACTORY->NewJSMessageObject(type_handle,
+ factory->NewJSMessageObject(type_handle,
arguments_handle,
start,
end,
v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception_handle);
- v8::NeanderArray global_listeners(FACTORY->message_listeners());
+ v8::NeanderArray global_listeners(isolate->factory()->message_listeners());
int global_length = global_listeners.length();
if (global_length == 0) {
DefaultMessageReport(isolate, loc, message);
public:
// Returns a message object for the API to use.
static Handle<JSMessageObject> MakeMessageObject(
+ Isolate* isolate,
const char* type,
MessageLocation* loc,
Vector< Handle<Object> > args,
} else {
Handle<Object> args[1] = {Handle<Name>(name)};
return isolate->Throw(
- *FACTORY->NewTypeError("object_not_extensible",
- HandleVector(args, 1)));
+ *isolate->factory()->NewTypeError("object_not_extensible",
+ HandleVector(args, 1)));
}
}
// Cycle detected.
HandleScope scope(isolate);
return isolate->Throw(
- *FACTORY->NewError("cyclic_proto", HandleVector<Object>(NULL, 0)));
+ *isolate->factory()->NewError("cyclic_proto",
+ HandleVector<Object>(NULL, 0)));
}
}
// Add the specified break point object.
void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
Handle<Object> break_point_object) {
+ Isolate* isolate = break_point_info->GetIsolate();
+
// If there was no break point objects before just set it.
if (break_point_info->break_point_objects()->IsUndefined()) {
break_point_info->set_break_point_objects(*break_point_object);
if (break_point_info->break_point_objects() == *break_point_object) return;
// If there was one break point object before replace with array.
if (!break_point_info->break_point_objects()->IsFixedArray()) {
- Handle<FixedArray> array = FACTORY->NewFixedArray(2);
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(2);
array->set(0, break_point_info->break_point_objects());
array->set(1, *break_point_object);
break_point_info->set_break_point_objects(*array);
Handle<FixedArray>(
FixedArray::cast(break_point_info->break_point_objects()));
Handle<FixedArray> new_array =
- FACTORY->NewFixedArray(old_array->length() + 1);
+ isolate->factory()->NewFixedArray(old_array->length() + 1);
for (int i = 0; i < old_array->length(); i++) {
// If the break point was there before just ignore.
if (old_array->get(i) == *break_point_object) return;
Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) {
+ Factory* factory = Isolate::Current()->factory();
ASSERT(IsCompileTimeValue(expression));
- Handle<FixedArray> result = FACTORY->NewFixedArray(2, TENURED);
+ Handle<FixedArray> result = factory->NewFixedArray(2, TENURED);
ObjectLiteral* object_literal = expression->AsObjectLiteral();
if (object_literal != NULL) {
ASSERT(object_literal->is_simple());
}
Handle<JSArray> ToJSArray(Handle<JSArray> target_array) {
- FACTORY->SetContent(target_array, array_);
+ Factory* factory = target_array->GetIsolate()->factory();
+ factory->SetContent(target_array, array_);
target_array->set_length(Smi::FromInt(length_));
return target_array;
}
// called using 'new' and creates a new JSFunction object that
// is returned. The receiver object is only used for error
// reporting if an error occurs when constructing the new
- // JSFunction. FACTORY->NewJSObject() should not be used to
+ // JSFunction. Factory::NewJSObject() should not be used to
// allocate JSFunctions since it does not properly initialize
// the shared part of the function. Since the receiver is
// ignored anyway, we use the global object as the receiver
// Scan the heap for Script objects to find the script with the requested
// script data.
Handle<Script> script;
+ Factory* factory = script_name->GetIsolate()->factory();
Heap* heap = script_name->GetHeap();
heap->EnsureHeapIsIterable();
DisallowHeapAllocation no_allocation_during_heap_iteration;
}
// If no script with the requested script data is found return undefined.
- if (script.is_null()) return FACTORY->undefined_value();
+ if (script.is_null()) return factory->undefined_value();
// Return the script found.
return GetScriptWrapper(script);
+ parameter_count + stack_local_count + 2 * context_local_count
+ (has_function_name ? 2 : 0);
- Handle<ScopeInfo> scope_info = FACTORY->NewScopeInfo(length);
+ Factory* factory = Isolate::Current()->factory();
+ Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length);
// Encode the flags.
int flags = TypeField::encode(scope->type()) |
Handle<String> StringStream::ToString() {
- return FACTORY->NewStringFromUtf8(Vector<const char>(buffer_, length_));
+ Factory* factory = Isolate::Current()->factory();
+ return factory->NewStringFromUtf8(Vector<const char>(buffer_, length_));
}
HandleScope scope(isolate);
Handle<Name> name_handle(name);
Handle<Object> error =
- FACTORY->NewReferenceError("not_defined",
- HandleVector(&name_handle, 1));
+ isolate->factory()->NewReferenceError("not_defined",
+ HandleVector(&name_handle, 1));
return isolate->Throw(*error);
}
: 0;
int length = infos->length() + cell_count;
byte* old_start = code->instruction_start();
- dictionary_ = FACTORY->NewUnseededNumberDictionary(length);
+ dictionary_ = isolate()->factory()->NewUnseededNumberDictionary(length);
byte* new_start = code->instruction_start();
RelocateRelocInfos(infos, old_start, new_start);
}
__ bind(&check_for_nan);
}
- // 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.
Label heap_number;
// If it's not a heap number, then return equal for (in)equality operator.
static const int kOffsetToResultValue = 18;
// The last 4 bytes of the instruction sequence
// movq(rdi, FieldOperand(rax, HeapObject::kMapOffset))
- // Move(kScratchRegister, FACTORY->the_hole_value())
+ // Move(kScratchRegister, Factory::the_hole_value())
// in front of the hole value address.
static const unsigned int kWordBeforeMapCheckValue = 0xBA49FF78;
// The last 4 bytes of the instruction sequence
__ jmp(&entry);
__ bind(&loop);
__ movq(rdx, FieldOperand(rbx, 0));
- __ Cmp(rdx, FACTORY->value_of_string());
+ __ Cmp(rdx, isolate()->factory()->value_of_string());
__ j(equal, if_false);
__ addq(rbx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize));
__ bind(&entry);
TEST(StressJS) {
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Handle<v8::Context> env = v8::Context::New(v8::Isolate::GetCurrent());
env->Enter();
Handle<JSFunction> function =
- FACTORY->NewFunction(FACTORY->function_string(), FACTORY->null_value());
+ factory->NewFunction(factory->function_string(), factory->null_value());
// Force the creation of an initial map and set the code to
// something empty.
- FACTORY->NewJSObject(function);
+ factory->NewJSObject(function);
function->ReplaceCode(Isolate::Current()->builtins()->builtin(
Builtins::kEmptyFunction));
// Patch the map to have an accessor for "get".
Handle<Map> map(function->initial_map());
Handle<DescriptorArray> instance_descriptors(map->instance_descriptors());
- Handle<Foreign> foreign = FACTORY->NewForeign(&kDescriptor);
+ Handle<Foreign> foreign = factory->NewForeign(&kDescriptor);
Handle<String> name =
- FACTORY->NewStringFromAscii(Vector<const char>("get", 3));
+ factory->NewStringFromAscii(Vector<const char>("get", 3));
ASSERT(instance_descriptors->IsEmpty());
- Handle<DescriptorArray> new_descriptors = FACTORY->NewDescriptorArray(0, 1);
+ Handle<DescriptorArray> new_descriptors = factory->NewDescriptorArray(0, 1);
v8::internal::DescriptorArray::WhitenessWitness witness(*new_descriptors);
map->set_instance_descriptors(*new_descriptors);
THREADED_TEST(UsingExternalString) {
+ i::Factory* factory = i::Isolate::Current()->factory();
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
uint16_t* two_byte_string = AsciiToTwoByteString("test string");
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
i::Handle<i::String> isymbol =
- FACTORY->InternalizedStringFromString(istring);
+ factory->InternalizedStringFromString(istring);
CHECK(isymbol->IsInternalizedString());
}
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
THREADED_TEST(UsingExternalAsciiString) {
+ i::Factory* factory = i::Isolate::Current()->factory();
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
const char* one_byte_string = "test string";
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
i::Handle<i::String> isymbol =
- FACTORY->InternalizedStringFromString(istring);
+ factory->InternalizedStringFromString(istring);
CHECK(isymbol->IsInternalizedString());
}
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
uint16_t* two_byte_string = AsciiToTwoByteString(c_string);
{
LocalContext env;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(env->GetIsolate());
AsciiVectorResource ascii_resource(
i::Vector<const char>(c_string, i::StrLength(c_string)));
i::StrLength(c_string)));
Local<String> lhs(v8::Utils::ToLocal(
- FACTORY->NewExternalStringFromAscii(&ascii_resource)));
+ factory->NewExternalStringFromAscii(&ascii_resource)));
Local<String> rhs(v8::Utils::ToLocal(
- FACTORY->NewExternalStringFromAscii(&ascii_resource)));
+ factory->NewExternalStringFromAscii(&ascii_resource)));
env->Global()->Set(v8_str("lhs"), lhs);
env->Global()->Set(v8_str("rhs"), rhs);
uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {}
~RegExpStringModificationTest() { delete block_; }
void RunTest() {
+ i::Factory* factory = i::Isolate::Current()->factory();
+
regexp_success_ = false;
morph_success_ = false;
// Create the input string for the regexp - the one we are going to change
// properties of.
- input_ = FACTORY->NewExternalStringFromAscii(&ascii_resource_);
+ input_ = factory->NewExternalStringFromAscii(&ascii_resource_);
// Inject the input as a global variable.
i::Handle<i::String> input_name =
- FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5));
+ factory->NewStringFromAscii(i::Vector<const char>("input", 5));
i::Isolate::Current()->native_context()->global_object()->SetProperty(
*input_name,
*input_,
THREADED_TEST(PixelArray) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 260;
uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
i::Handle<i::ExternalPixelArray> pixels =
i::Handle<i::ExternalPixelArray>::cast(
- FACTORY->NewExternalArray(kElementCount,
+ factory->NewExternalArray(kElementCount,
v8::kExternalPixelArray,
pixel_data));
// Force GC to trigger verification.
THREADED_TEST(PixelArrayWithInterceptor) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 260;
uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
i::Handle<i::ExternalPixelArray> pixels =
i::Handle<i::ExternalPixelArray>::cast(
- FACTORY->NewExternalArray(kElementCount,
+ factory->NewExternalArray(kElementCount,
v8::kExternalPixelArray,
pixel_data));
for (int i = 0; i < kElementCount; i++) {
int64_t low,
int64_t high) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 40;
int element_size = ExternalArrayElementSize(array_type);
static_cast<ElementType*>(malloc(kElementCount * element_size));
i::Handle<ExternalArrayClass> array =
i::Handle<ExternalArrayClass>::cast(
- FACTORY->NewExternalArray(kElementCount, array_type, array_data));
+ factory->NewExternalArray(kElementCount, array_type, array_data));
// Force GC to trigger verification.
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
for (int i = 0; i < kElementCount; i++) {
}
static void CreateGarbageInOldSpace() {
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::HandleScope scope(v8::Isolate::GetCurrent());
i::AlwaysAllocateScope always_allocate;
for (int i = 0; i < 1000; i++) {
- FACTORY->NewFixedArray(1000, i::TENURED);
+ factory->NewFixedArray(1000, i::TENURED);
}
}
TEST(StaticGetters) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
- i::Handle<i::Object> undefined_value = FACTORY->undefined_value();
+ i::Handle<i::Object> undefined_value = factory->undefined_value();
CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
- i::Handle<i::Object> null_value = FACTORY->null_value();
+ i::Handle<i::Object> null_value = factory->null_value();
CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value);
CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value);
- i::Handle<i::Object> true_value = FACTORY->true_value();
+ i::Handle<i::Object> true_value = factory->true_value();
CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
- i::Handle<i::Object> false_value = FACTORY->false_value();
+ i::Handle<i::Object> false_value = factory->false_value();
CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
TEST(StringEmpty) {
LocalContext context;
+ i::Factory* factory = i::Isolate::Current()->factory();
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
- i::Handle<i::Object> empty_string = FACTORY->empty_string();
+ i::Handle<i::Object> empty_string = factory->empty_string();
CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
// some relocated stuff here, not executed
__ RecordComment("dead code, just testing relocations");
- __ mov(r0, Operand(FACTORY->true_value()));
+ __ mov(r0, Operand(isolate->factory()->true_value()));
__ RecordComment("dead code, just testing immediate operands");
__ mov(r0, Operand(-1));
__ mov(r0, Operand(0xFF000000));
__ ret(0);
// some relocated stuff here, not executed
- __ mov(eax, FACTORY->true_value());
+ __ mov(eax, isolate->factory()->true_value());
__ jmp(NULL, RelocInfo::RUNTIME_ENTRY);
CodeDesc desc;
static MaybeObject* GetGlobalProperty(const char* name) {
- Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name);
- return Isolate::Current()->context()->global_object()->GetProperty(
- *internalized_name);
+ Isolate* isolate = Isolate::Current();
+ Handle<String> internalized_name =
+ isolate->factory()->InternalizeUtf8String(name);
+ return isolate->context()->global_object()->GetProperty(*internalized_name);
}
static Handle<JSFunction> Compile(const char* source) {
- Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source)));
+ Isolate* isolate = Isolate::Current();
+ Handle<String> source_code(
+ isolate->factory()->NewStringFromUtf8(CStrVector(source)));
Handle<SharedFunctionInfo> shared_function =
Compiler::Compile(source_code,
Handle<String>(),
0,
0,
- Handle<Context>(Isolate::Current()->native_context()),
+ Handle<Context>(isolate->native_context()),
NULL,
NULL,
Handle<String>::null(),
NOT_NATIVES_CODE);
- return FACTORY->NewFunctionFromSharedFunctionInfo(shared_function,
- Isolate::Current()->native_context());
+ return isolate->factory()->NewFunctionFromSharedFunctionInfo(
+ shared_function, isolate->native_context());
}
Execution::Call(fun0, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception);
- Object* foo_string =
- FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("foo"))->
- ToObjectChecked();
+ Object* foo_string = isolate->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("foo"))->ToObjectChecked();
MaybeObject* fun1_object = isolate->context()->global_object()->
GetProperty(String::cast(foo_string));
Handle<Object> fun1(fun1_object->ToObjectChecked(), isolate);
CHECK(fun1->IsJSFunction());
- Handle<Object> argv[] =
- { FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("hello")) };
+ Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("hello")) };
Execution::Call(Handle<JSFunction>::cast(fun1),
global,
ARRAY_SIZE(argv),
// source resulted in crash.
TEST(Regression236) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
- Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string());
+ Handle<Script> script = factory->NewScript(factory->empty_string());
script->set_source(HEAP->undefined_value());
CHECK_EQ(-1, GetScriptLineNumber(script, 0));
CHECK_EQ(-1, GetScriptLineNumber(script, 100));
void ExposeDebug() {
v8::internal::Isolate* isolate =
reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate());
+ v8::internal::Factory* factory = isolate->factory();
v8::internal::Debug* debug = isolate->debug();
// Expose the debug context global object in the global object for testing.
debug->Load();
Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast(
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
- FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
+ factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
SetProperty(isolate, global, debug_string,
Handle<Object>(debug->debug_context()->global_proxy(), isolate),
DONT_ENUM,
// Allocate array for the debugged functions
Handle<FixedArray> debugged_functions =
- FACTORY->NewFixedArray(count);
+ Isolate::Current()->factory()->NewFixedArray(count);
// Run through the debug info objects and collect all functions.
count = 0;
TEST(ObjectHashTable) {
LocalContext context;
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
- Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(23);
- Handle<JSObject> a = FACTORY->NewJSArray(7);
- Handle<JSObject> b = FACTORY->NewJSArray(11);
+ Handle<ObjectHashTable> table = factory->NewObjectHashTable(23);
+ Handle<JSObject> a = factory->NewJSArray(7);
+ Handle<JSObject> b = factory->NewJSArray(11);
table = PutIntoObjectHashTable(table, a, b);
CHECK_EQ(table->NumberOfElements(), 1);
CHECK_EQ(table->Lookup(*a), *b);
CHECK_EQ(table->Lookup(*b), HEAP->the_hole_value());
// Keys that are overwritten should not change number of elements.
- table = PutIntoObjectHashTable(table, a, FACTORY->NewJSArray(13));
+ table = PutIntoObjectHashTable(table, a, factory->NewJSArray(13));
CHECK_EQ(table->NumberOfElements(), 1);
CHECK_NE(table->Lookup(*a), *b);
// Keys mapped to the hole should be removed permanently.
- table = PutIntoObjectHashTable(table, a, FACTORY->the_hole_value());
+ table = PutIntoObjectHashTable(table, a, factory->the_hole_value());
CHECK_EQ(table->NumberOfElements(), 0);
CHECK_EQ(table->NumberOfDeletedElements(), 1);
CHECK_EQ(table->Lookup(*a), HEAP->the_hole_value());
// Keys should map back to their respective values and also should get
// an identity hash code generated.
for (int i = 0; i < 100; i++) {
- Handle<JSObject> key = FACTORY->NewJSArray(7);
- Handle<JSObject> value = FACTORY->NewJSArray(11);
+ Handle<JSObject> key = factory->NewJSArray(7);
+ Handle<JSObject> value = factory->NewJSArray(11);
table = PutIntoObjectHashTable(table, key, value);
CHECK_EQ(table->NumberOfElements(), i + 1);
CHECK_NE(table->FindEntry(*key), ObjectHashTable::kNotFound);
// Keys never added to the map which already have an identity hash
// code should not be found.
for (int i = 0; i < 100; i++) {
- Handle<JSObject> key = FACTORY->NewJSArray(7);
+ Handle<JSObject> key = factory->NewJSArray(7);
CHECK(key->GetIdentityHash(ALLOW_CREATION)->ToObjectChecked()->IsSmi());
CHECK_EQ(table->FindEntry(*key), ObjectHashTable::kNotFound);
CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
// Keys that don't have an identity hash should not be found and also
// should not get an identity hash code generated.
for (int i = 0; i < 100; i++) {
- Handle<JSObject> key = FACTORY->NewJSArray(7);
+ Handle<JSObject> key = factory->NewJSArray(7);
CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value());
}
#ifdef DEBUG
TEST(ObjectHashSetCausesGC) {
LocalContext context;
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
- Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1);
- Handle<JSObject> key = FACTORY->NewJSArray(0);
+ Handle<ObjectHashSet> table = factory->NewObjectHashSet(1);
+ Handle<JSObject> key = factory->NewJSArray(0);
v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
// Force allocation of hash table backing store for hidden properties.
#ifdef DEBUG
TEST(ObjectHashTableCausesGC) {
LocalContext context;
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(context->GetIsolate());
- Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1);
- Handle<JSObject> key = FACTORY->NewJSArray(0);
+ Handle<ObjectHashTable> table = factory->NewObjectHashTable(1);
+ Handle<JSObject> key = factory->NewJSArray(0);
v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
// Force allocation of hash table backing store for hidden properties.
__ sub(eax, Immediate(12345678));
__ xor_(eax, 12345678);
__ and_(eax, 12345678);
- Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED);
+ Handle<FixedArray> foo = isolate->factory()->NewFixedArray(10, TENURED);
__ cmp(eax, foo);
// ---- This one caused crash
__ cmp(edx, 3);
__ cmp(edx, Operand(esp, 4));
__ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000));
- Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED);
+ Handle<FixedArray> foo2 = isolate->factory()->NewFixedArray(10, TENURED);
__ cmp(ebx, foo2);
__ cmpb(ebx, Operand(ebp, ecx, times_2, 0));
__ cmpb(Operand(ebp, ecx, times_2, 0), ebx);
static void CheckFunctionName(v8::Handle<v8::Script> script,
const char* func_pos_src,
const char* ref_inferred_name) {
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+
// Get script source.
Handle<Object> obj = v8::Utils::OpenHandle(*script);
Handle<SharedFunctionInfo> shared_function;
// Find the position of a given func source substring in the source.
Handle<String> func_pos_str =
- FACTORY->NewStringFromAscii(CStrVector(func_pos_src));
- int func_pos = Runtime::StringMatch(Isolate::Current(),
+ factory->NewStringFromAscii(CStrVector(func_pos_src));
+ int func_pos = Runtime::StringMatch(isolate,
script_src,
func_pos_str,
0);
#ifdef ENABLE_DEBUGGER_SUPPORT
// Obtain SharedFunctionInfo for the function.
- Isolate::Current()->debug()->PrepareForBreakPoints();
+ isolate->debug()->PrepareForBreakPoints();
Object* shared_func_info_ptr =
- Isolate::Current()->debug()->FindSharedFunctionInfoInScript(i_script,
- func_pos);
+ isolate->debug()->FindSharedFunctionInfoInScript(i_script, func_pos);
CHECK(shared_func_info_ptr != HEAP->undefined_value());
Handle<SharedFunctionInfo> shared_func_info(
SharedFunctionInfo::cast(shared_func_info_ptr));
TEST(HeapObjects) {
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
HandleScope sc(isolate);
CHECK(heap->nan_value()->IsNumber());
CHECK(std::isnan(heap->nan_value()->Number()));
- Handle<String> s = FACTORY->NewStringFromAscii(CStrVector("fisk hest "));
+ Handle<String> s = factory->NewStringFromAscii(CStrVector("fisk hest "));
CHECK(s->IsString());
CHECK_EQ(10, s->length());
TEST(LocalHandles) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* name = "Kasper the spunky";
- Handle<String> string = FACTORY->NewStringFromAscii(CStrVector(name));
+ Handle<String> string = factory->NewStringFromAscii(CStrVector(name));
CHECK_EQ(StrLength(name), string->length());
}
TEST(FunctionAllocation) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
+ Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function =
- FACTORY->NewFunction(name, FACTORY->undefined_value());
+ factory->NewFunction(name, factory->undefined_value());
Handle<Map> initial_map =
- FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Handle<String> prop_name = FACTORY->InternalizeUtf8String("theSlot");
- Handle<JSObject> obj = FACTORY->NewJSObject(function);
+ Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
+ Handle<JSObject> obj = factory->NewJSObject(function);
obj->SetProperty(
*prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
TEST(ObjectProperties) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(HEAP->Object_string());
GetProperty(object_string)->ToObjectChecked();
JSFunction* object_function = JSFunction::cast(raw_object);
Handle<JSFunction> constructor(object_function);
- Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
- Handle<String> first = FACTORY->InternalizeUtf8String("first");
- Handle<String> second = FACTORY->InternalizeUtf8String("second");
+ Handle<JSObject> obj = factory->NewJSObject(constructor);
+ Handle<String> first = factory->InternalizeUtf8String("first");
+ Handle<String> second = factory->InternalizeUtf8String("second");
// check for empty
CHECK(!obj->HasLocalProperty(*first));
// check string and internalized string match
const char* string1 = "fisk";
- Handle<String> s1 = FACTORY->NewStringFromAscii(CStrVector(string1));
+ Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1));
obj->SetProperty(
*s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- Handle<String> s1_string = FACTORY->InternalizeUtf8String(string1);
+ Handle<String> s1_string = factory->InternalizeUtf8String(string1);
CHECK(obj->HasLocalProperty(*s1_string));
// check internalized string and string match
const char* string2 = "fugl";
- Handle<String> s2_string = FACTORY->InternalizeUtf8String(string2);
+ Handle<String> s2_string = factory->InternalizeUtf8String(string2);
obj->SetProperty(
*s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- Handle<String> s2 = FACTORY->NewStringFromAscii(CStrVector(string2));
+ Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2));
CHECK(obj->HasLocalProperty(*s2));
}
TEST(JSObjectMaps) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
+ Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function =
- FACTORY->NewFunction(name, FACTORY->undefined_value());
+ factory->NewFunction(name, factory->undefined_value());
Handle<Map> initial_map =
- FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Handle<String> prop_name = FACTORY->InternalizeUtf8String("theSlot");
- Handle<JSObject> obj = FACTORY->NewJSObject(function);
+ Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
+ Handle<JSObject> obj = factory->NewJSObject(function);
// Set a propery
obj->SetProperty(
TEST(JSArray) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
- Handle<String> name = FACTORY->InternalizeUtf8String("Array");
+ Handle<String> name = factory->InternalizeUtf8String("Array");
Object* raw_object = Isolate::Current()->context()->global_object()->
GetProperty(*name)->ToObjectChecked();
Handle<JSFunction> function = Handle<JSFunction>(
JSFunction::cast(raw_object));
// Allocate the object.
- Handle<JSObject> object = FACTORY->NewJSObject(function);
+ Handle<JSObject> object = factory->NewJSObject(function);
Handle<JSArray> array = Handle<JSArray>::cast(object);
// We just initialized the VM, no heap allocation failure yet.
array->Initialize(0)->ToObjectChecked();
// Set array length with larger than smi value.
Handle<Object> length =
- FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
+ factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
array->SetElementsLength(*length)->ToObjectChecked();
uint32_t int_length = 0;
TEST(JSObjectCopy) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(HEAP->Object_string());
GetProperty(object_string)->ToObjectChecked();
JSFunction* object_function = JSFunction::cast(raw_object);
Handle<JSFunction> constructor(object_function);
- Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
- Handle<String> first = FACTORY->InternalizeUtf8String("first");
- Handle<String> second = FACTORY->InternalizeUtf8String("second");
+ Handle<JSObject> obj = factory->NewJSObject(constructor);
+ Handle<String> first = factory->InternalizeUtf8String("first");
+ Handle<String> second = factory->InternalizeUtf8String("second");
obj->SetProperty(
*first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
TEST(StringAllocation) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
for (int length = 0; length < 100; length++) {
non_ascii[3 * i + 2] = chars[2];
}
Handle<String> non_ascii_sym =
- FACTORY->InternalizeUtf8String(
+ factory->InternalizeUtf8String(
Vector<const char>(non_ascii, 3 * length));
CHECK_EQ(length, non_ascii_sym->length());
Handle<String> ascii_sym =
- FACTORY->InternalizeOneByteString(OneByteVector(ascii, length));
+ factory->InternalizeOneByteString(OneByteVector(ascii, length));
CHECK_EQ(length, ascii_sym->length());
Handle<String> non_ascii_str =
- FACTORY->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
+ factory->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
non_ascii_str->Hash();
CHECK_EQ(length, non_ascii_str->length());
Handle<String> ascii_str =
- FACTORY->NewStringFromUtf8(Vector<const char>(ascii, length));
+ factory->NewStringFromUtf8(Vector<const char>(ascii, length));
ascii_str->Hash();
CHECK_EQ(length, ascii_str->length());
DeleteArray(non_ascii);
TEST(Iteration) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
// Array of objects to scan haep for.
int next_objs_index = 0;
// Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE
- objs[next_objs_index++] = FACTORY->NewJSArray(10);
- objs[next_objs_index++] = FACTORY->NewJSArray(10,
+ objs[next_objs_index++] = factory->NewJSArray(10);
+ objs[next_objs_index++] = factory->NewJSArray(10,
FAST_HOLEY_ELEMENTS,
TENURED);
// Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector("abcdefghij"));
+ factory->NewStringFromAscii(CStrVector("abcdefghij"));
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
+ factory->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
// Allocate a large string (for large object space).
int large_size = Page::kMaxNonCodeHeapObjectSize + 1;
for (int i = 0; i < large_size - 1; ++i) str[i] = 'a';
str[large_size - 1] = '\0';
objs[next_objs_index++] =
- FACTORY->NewStringFromAscii(CStrVector(str), TENURED);
+ factory->NewStringFromAscii(CStrVector(str), TENURED);
delete[] str;
// Add a Map object to look for.
TEST(Regression39128) {
// Test case for crbug.com/39128.
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
// Increase the chance of 'bump-the-pointer' allocation in old space.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK(object_ctor->has_initial_map());
Handle<Map> object_map(object_ctor->initial_map());
// Create a map with single inobject property.
- Handle<Map> my_map = FACTORY->CopyMap(object_map, 1);
+ Handle<Map> my_map = factory->CopyMap(object_map, 1);
int n_properties = my_map->inobject_properties();
CHECK_GT(n_properties, 0);
if (!FLAG_flush_code) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var x = 42;"
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var x = 42;"
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
const char* source = "var foo = function() {"
" var x = 42;"
" var x = 23;"
"};"
"bar();";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
- Handle<String> bar_name = FACTORY->InternalizeUtf8String("bar");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
+ Handle<String> bar_name = factory->InternalizeUtf8String("bar");
// Perfrom one initial GC to enable code flushing.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {"
" var z = x + y;"
"};"
"foo()";
- Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
// This compile will add the code to the compilation cache.
{ v8::HandleScope scope(CcTest::isolate());
TEST(PrototypeTransitionClearing) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
CompileRun(
{
AlwaysAllocateScope always_allocate;
SimulateFullSpace(space);
- prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
+ prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
}
// Add a prototype on an evacuation candidate and verify that transition
i::FLAG_crankshaft = false;
i::FLAG_always_opt = false;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
static const int number_of_test_pages = 20;
for (int i = 0; i < number_of_test_pages; i++) {
AlwaysAllocateScope always_allocate;
SimulateFullSpace(old_pointer_space);
- FACTORY->NewFixedArray(1, TENURED);
+ factory->NewFixedArray(1, TENURED);
}
CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
TEST(Regress2237) {
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
Handle<String> slice(HEAP->empty_string());
// Generate a parent that lives in new-space.
v8::HandleScope inner_scope(CcTest::isolate());
const char* c = "This text is long enough to trigger sliced strings.";
- Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c));
+ Handle<String> s = factory->NewStringFromAscii(CStrVector(c));
CHECK(s->IsSeqOneByteString());
CHECK(HEAP->InNewSpace(*s));
// lives in old-space.
SimulateFullSpace(HEAP->new_space());
AlwaysAllocateScope always_allocate;
- Handle<String> t = FACTORY->NewProperSubString(s, 5, 35);
+ Handle<String> t = factory->NewProperSubString(s, 5, 35);
CHECK(t->IsSlicedString());
CHECK(!HEAP->InNewSpace(*t));
*slice.location() = *t.location();
i::FLAG_allow_natives_syntax = true;
i::FLAG_crankshaft = false;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
// Some flags turn Scavenge collections into Mark-sweep collections
HEAP->CollectGarbage(NEW_SPACE);
// Allocate the object.
- Handle<FixedArray> array_data = FACTORY->NewFixedArray(2, NOT_TENURED);
+ Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
array_data->set(0, Smi::FromInt(1));
array_data->set(1, Smi::FromInt(2));
JSArray::kSize + AllocationSiteInfo::kSize +
kPointerSize);
- Handle<JSArray> array = FACTORY->NewJSArrayWithElements(array_data,
+ Handle<JSArray> array = factory->NewJSArrayWithElements(array_data,
FAST_SMI_ELEMENTS,
NOT_TENURED);
// TODO(1600): compaction of map space is temporary removed from GC.
#if 0
-static Handle<Map> CreateMap() {
- return FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+static Handle<Map> CreateMap(Isolate* isolate) {
+ return isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
}
TEST(MapCompact) {
FLAG_max_map_space_pages = 16;
CcTest::InitializeVM();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
{
v8::HandleScope sc;
// keep allocating maps while pointers are still encodable and thus
// mark compact is permitted.
- Handle<JSObject> root = FACTORY->NewJSObjectFromMap(CreateMap());
+ Handle<JSObject> root = factory->NewJSObjectFromMap(CreateMap());
do {
Handle<Map> map = CreateMap();
map->set_prototype(*root);
- root = FACTORY->NewJSObjectFromMap(map);
+ root = factory->NewJSObjectFromMap(map);
} while (HEAP->map_space()->MapPointersEncodable());
}
// Now, as we don't have any handles to just allocated maps, we should
"Object.observe(obj, function(){});"
"Object.getNotifier(obj);"
"obj = null;");
- i::Handle<i::JSObject> observation_state = FACTORY->observation_state();
+ i::Handle<i::JSObject> observation_state =
+ i::Isolate::Current()->factory()->observation_state();
i::Handle<i::JSWeakMap> observerInfoMap =
i::Handle<i::JSWeakMap>::cast(
i::GetProperty(observation_state, "observerInfoMap"));
TEST(Regress928) {
v8::V8::Initialize();
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
// Preparsing didn't consider the catch clause of a try statement
// as with-content, which made it assume that a function inside
// the block could be lazily compiled, and an extra, unexpected,
// entry was added to the data.
int marker;
- i::Isolate::Current()->stack_guard()->SetStackLimit(
+ isolate->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
const char* program =
v8::HandleScope handles(v8::Isolate::GetCurrent());
i::Handle<i::String> source(
- FACTORY->NewStringFromAscii(i::CStrVector(program)));
+ factory->NewStringFromAscii(i::CStrVector(program)));
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
i::ScriptDataImpl* data = i::PreParserApi::PreParse(&stream);
CHECK(!data->HasError());
unsigned end = 0) {
if (end == 0) end = length;
unsigned sub_length = end - start;
- i::HandleScope test_scope(i::Isolate::Current());
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+ i::HandleScope test_scope(isolate);
i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]);
for (unsigned i = 0; i < length; i++) {
uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]);
}
i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length));
i::Handle<i::String> ascii_string(
- FACTORY->NewStringFromAscii(ascii_vector));
+ factory->NewStringFromAscii(ascii_vector));
TestExternalResource resource(*uc16_buffer, length);
i::Handle<i::String> uc16_string(
- FACTORY->NewExternalStringFromTwoByte(&resource));
+ factory->NewExternalStringFromTwoByte(&resource));
i::ExternalTwoByteStringUtf16CharacterStream uc16_stream(
i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end);
{ NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE }
};
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+
v8::HandleScope handles(v8::Isolate::GetCurrent());
v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
v8::Context::Scope context_scope(context);
int marker;
- i::Isolate::Current()->stack_guard()->SetStackLimit(
+ isolate->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
for (int i = 0; source_data[i].outer_prefix; i++) {
// Parse program source.
i::Handle<i::String> source(
- FACTORY->NewStringFromUtf8(i::CStrVector(program.start())));
+ factory->NewStringFromUtf8(i::CStrVector(program.start())));
CHECK_EQ(source->length(), kProgramSize);
- i::Handle<i::Script> script = FACTORY->NewScript(source);
+ i::Handle<i::Script> script = factory->NewScript(source);
i::CompilationInfoWithZone info(script);
i::Parser parser(&info);
parser.set_allow_lazy(true);
i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
i::Handle<i::String> format = v8::Utils::OpenHandle(
*v8::String::New(data->BuildMessage()));
i::Vector<const char*> args = data->BuildArgs();
- i::Handle<i::JSArray> args_array = FACTORY->NewJSArray(args.length());
+ i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
for (int i = 0; i < args.length(); i++) {
i::JSArray::SetElement(args_array,
i,
NONE,
i::kNonStrictMode);
}
- i::Handle<i::JSObject> builtins(i::Isolate::Current()->js_builtins_object());
+ i::Handle<i::JSObject> builtins(isolate->js_builtins_object());
i::Handle<i::Object> format_fun =
i::GetProperty(builtins, "FormatMessage");
i::Handle<i::Object> arg_handles[] = { format, args_array };
parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators));
void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) {
- uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit();
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+
+ uintptr_t stack_limit = isolate->stack_guard()->real_climit();
// Preparse the data.
i::CompleteParserRecorder log;
{
- i::Scanner scanner(i::Isolate::Current()->unicode_cache());
+ i::Scanner scanner(isolate->unicode_cache());
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
v8::preparser::PreParser preparser(&scanner, &log, stack_limit);
SET_PARSER_FLAGS(preparser, flags);
// Parse the data
i::FunctionLiteral* function;
{
- i::Handle<i::Script> script = FACTORY->NewScript(source);
+ i::Handle<i::Script> script = factory->NewScript(source);
i::CompilationInfoWithZone info(script);
i::Parser parser(&info);
SET_PARSER_FLAGS(parser, flags);
// Check that preparsing fails iff parsing fails.
if (function == NULL) {
// Extract exception from the parser.
- CHECK(i::Isolate::Current()->has_pending_exception());
- i::MaybeObject* maybe_object = i::Isolate::Current()->pending_exception();
+ CHECK(isolate->has_pending_exception());
+ i::MaybeObject* maybe_object = isolate->pending_exception();
i::JSObject* exception = NULL;
CHECK(maybe_object->To(&exception));
i::Handle<i::JSObject> exception_handle(exception);
// correct timeout for this and re-enable this test again.
if (i::FLAG_stress_compaction) return;
+ i::Isolate* isolate = i::Isolate::Current();
+ i::Factory* factory = isolate->factory();
+
v8::HandleScope handles(v8::Isolate::GetCurrent());
v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
v8::Context::Scope context_scope(context);
int marker;
- i::Isolate::Current()->stack_guard()->SetStackLimit(
+ isolate->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
for (int i = 0; context_data[i][0] != NULL; ++i) {
context_data[i][1]);
CHECK(length == kProgramSize);
i::Handle<i::String> source =
- FACTORY->NewStringFromAscii(i::CStrVector(program.start()));
+ factory->NewStringFromAscii(i::CStrVector(program.start()));
TestParserSync(source);
}
}
CompileRun("function f() { return Math.random(); }");
- Object* string = FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("f"))->
- ToObjectChecked();
+ Object* string = Isolate::Current()->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("f"))->ToObjectChecked();
MaybeObject* fun_object =
context->global_object()->GetProperty(String::cast(string));
Handle<JSFunction> fun(JSFunction::cast(fun_object->ToObjectChecked()));
static void SanityCheck() {
+ Isolate* isolate = Isolate::Current();
v8::HandleScope scope(v8::Isolate::GetCurrent());
#ifdef VERIFY_HEAP
HEAP->Verify();
#endif
- CHECK(Isolate::Current()->global_object()->IsJSObject());
- CHECK(Isolate::Current()->native_context()->IsContext());
+ CHECK(isolate->global_object()->IsJSObject());
+ CHECK(isolate->native_context()->IsContext());
CHECK(HEAP->string_table()->IsStringTable());
- CHECK(!FACTORY->InternalizeOneByteString(
+ CHECK(!isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("Empty"))->IsFailure());
}
RandomNumberGenerator* rng) {
// A list of pointers that we don't have any interest in cleaning up.
// If they are reachable from a root then leak detection won't complain.
- Zone* zone = Isolate::Current()->runtime_zone();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone* zone = isolate->runtime_zone();
for (int i = 0; i < bb_length; i++) {
int len = rng->next(16);
int slice_head_chars = 0;
buf[j] = rng->next(0x10000);
}
building_blocks[i] =
- FACTORY->NewStringFromTwoByte(Vector<const uc16>(buf, len));
+ factory->NewStringFromTwoByte(Vector<const uc16>(buf, len));
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
buf[j] = rng->next(0x80);
}
building_blocks[i] =
- FACTORY->NewStringFromAscii(Vector<const char>(buf, len));
+ factory->NewStringFromAscii(Vector<const char>(buf, len));
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
buf[j] = rng->next(0x10000);
}
Resource* resource = new(zone) Resource(Vector<const uc16>(buf, len));
- building_blocks[i] = FACTORY->NewExternalStringFromTwoByte(resource);
+ building_blocks[i] = factory->NewExternalStringFromTwoByte(resource);
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
}
AsciiResource* resource =
new(zone) AsciiResource(Vector<const char>(buf, len));
- building_blocks[i] = FACTORY->NewExternalStringFromAscii(resource);
+ building_blocks[i] = factory->NewExternalStringFromAscii(resource);
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
}
}
for (int j = slice_depth; j > 0; j--) {
- building_blocks[i] = FACTORY->NewSubString(
+ building_blocks[i] = factory->NewSubString(
building_blocks[i],
slice_head_chars,
building_blocks[i]->length() - slice_tail_chars);
static Handle<String> ConstructRandomString(ConsStringGenerationData* data,
unsigned max_recursion) {
+ Factory* factory = Isolate::Current()->factory();
// Compute termination characteristics.
bool terminate = false;
bool flat = data->rng_.next(data->empty_leaf_threshold_);
left = ConstructRandomString(data, max_recursion - 1);
}
// Build the cons string.
- Handle<String> root = FACTORY->NewConsString(left, right);
+ Handle<String> root = factory->NewConsString(left, right);
CHECK(root->IsConsString() && !root->IsFlat());
// Special work needed for flat string.
if (flat) {
static Handle<String> ConstructLeft(
ConsStringGenerationData* data,
int depth) {
- Handle<String> answer = FACTORY->NewStringFromAscii(CStrVector(""));
+ Factory* factory = Isolate::Current()->factory();
+ Handle<String> answer = factory->NewStringFromAscii(CStrVector(""));
data->stats_.leaves_++;
for (int i = 0; i < depth; i++) {
Handle<String> block = data->block(i);
- Handle<String> next = FACTORY->NewConsString(answer, block);
+ Handle<String> next = factory->NewConsString(answer, block);
if (next->IsConsString()) data->stats_.leaves_++;
data->stats_.chars_ += block->length();
answer = next;
static Handle<String> ConstructRight(
ConsStringGenerationData* data,
int depth) {
- Handle<String> answer = FACTORY->NewStringFromAscii(CStrVector(""));
+ Factory* factory = Isolate::Current()->factory();
+ Handle<String> answer = factory->NewStringFromAscii(CStrVector(""));
data->stats_.leaves_++;
for (int i = depth - 1; i >= 0; i--) {
Handle<String> block = data->block(i);
- Handle<String> next = FACTORY->NewConsString(block, answer);
+ Handle<String> next = factory->NewConsString(block, answer);
if (next->IsConsString()) data->stats_.leaves_++;
data->stats_.chars_ += block->length();
answer = next;
ConsStringGenerationData* data,
int from,
int to) {
+ Factory* factory = Isolate::Current()->factory();
CHECK(to > from);
if (to - from == 1) {
data->stats_.chars_ += data->block(from)->length();
if (to - from == 2) {
data->stats_.chars_ += data->block(from)->length();
data->stats_.chars_ += data->block(from+1)->length();
- return FACTORY->NewConsString(data->block(from), data->block(from+1));
+ return factory->NewConsString(data->block(from), data->block(from+1));
}
Handle<String> part1 =
ConstructBalancedHelper(data, from, from + ((to - from) / 2));
ConstructBalancedHelper(data, from + ((to - from) / 2), to);
if (part1->IsConsString()) data->stats_.left_traversals_++;
if (part2->IsConsString()) data->stats_.right_traversals_++;
- return FACTORY->NewConsString(part1, part2);
+ return factory->NewConsString(part1, part2);
}
static Handle<String> BuildEdgeCaseConsString(
int test_case, ConsStringGenerationData* data) {
+ Factory* factory = Isolate::Current()->factory();
data->Reset();
switch (test_case) {
case 0:
data->stats_.chars_ += data->block(0)->length();
data->stats_.chars_ += data->block(1)->length();
data->stats_.leaves_ += 2;
- return FACTORY->NewConsString(data->block(0), data->block(1));
+ return factory->NewConsString(data->block(0), data->block(1));
case 6:
// Simple flattened tree.
data->stats_.chars_ += data->block(0)->length();
data->stats_.empty_leaves_ += 1;
{
Handle<String> string =
- FACTORY->NewConsString(data->block(0), data->block(1));
+ factory->NewConsString(data->block(0), data->block(1));
FlattenString(string);
return string;
}
data->stats_.left_traversals_ += 1;
{
Handle<String> left =
- FACTORY->NewConsString(data->block(0), data->block(1));
+ factory->NewConsString(data->block(0), data->block(1));
FlattenString(left);
- return FACTORY->NewConsString(left, data->block(2));
+ return factory->NewConsString(left, data->block(2));
}
case 8:
// Left node and right node flattened.
data->stats_.right_traversals_ += 1;
{
Handle<String> left =
- FACTORY->NewConsString(data->block(0), data->block(1));
+ factory->NewConsString(data->block(0), data->block(1));
FlattenString(left);
Handle<String> right =
- FACTORY->NewConsString(data->block(2), data->block(2));
+ factory->NewConsString(data->block(2), data->block(2));
FlattenString(right);
- return FACTORY->NewConsString(left, right);
+ return factory->NewConsString(left, right);
}
}
UNREACHABLE();
TEST(DeepAscii) {
printf("TestDeepAscii\n");
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
char* foo = NewArray<char>(DEEP_ASCII_DEPTH);
foo[i] = "foo "[i % 4];
}
Handle<String> string =
- FACTORY->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH));
- Handle<String> foo_string = FACTORY->NewStringFromAscii(CStrVector("foo"));
+ factory->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH));
+ Handle<String> foo_string = factory->NewStringFromAscii(CStrVector("foo"));
for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) {
- string = FACTORY->NewConsString(string, foo_string);
+ string = factory->NewConsString(string, foo_string);
}
- Handle<String> flat_string = FACTORY->NewConsString(string, foo_string);
+ Handle<String> flat_string = factory->NewConsString(string, foo_string);
FlattenString(flat_string);
for (int i = 0; i < 500; i++) {
TEST(SliceFromCons) {
FLAG_string_slices = true;
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
Handle<String> string =
- FACTORY->NewStringFromAscii(CStrVector("parentparentparent"));
- Handle<String> parent = FACTORY->NewConsString(string, string);
+ factory->NewStringFromAscii(CStrVector("parentparentparent"));
+ Handle<String> parent = factory->NewConsString(string, string);
CHECK(parent->IsConsString());
CHECK(!parent->IsFlat());
- Handle<String> slice = FACTORY->NewSubString(parent, 1, 25);
+ Handle<String> slice = factory->NewSubString(parent, 1, 25);
// After slicing, the original string becomes a flat cons.
CHECK(parent->IsFlat());
CHECK(slice->IsSlicedString());
TEST(SliceFromExternal) {
FLAG_string_slices = true;
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
AsciiVectorResource resource(
i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
- Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource);
+ Handle<String> string = factory->NewExternalStringFromAscii(&resource);
CHECK(string->IsExternalString());
- Handle<String> slice = FACTORY->NewSubString(string, 1, 25);
+ Handle<String> slice = factory->NewSubString(string, 1, 25);
CHECK(slice->IsSlicedString());
CHECK(string->IsExternalString());
CHECK_EQ(SlicedString::cast(*slice)->parent(), *string);
// actually creates a new string (it should not).
FLAG_string_slices = true;
CcTest::InitializeVM();
+ Factory* factory = Isolate::Current()->factory();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> result;
Handle<String> string;
string = v8::Utils::OpenHandle(v8::String::Cast(*result));
CHECK(!string->IsSlicedString());
- string = FACTORY->NewSubString(string, 0, 26);
+ string = factory->NewSubString(string, 0, 26);
CHECK(!string->IsSlicedString());
result = CompileRun(crosscheck);
CHECK(result->IsString());