Included mjsunit JavaScript test suite and C++ unit tests.
Changed the shell sample to not print the result of executing a script provided on the command line.
Fixed issue when building samples on Windows using a shared V8 library. Added visibility option on Linux build which makes the generated library 18% smaller.
Changed build system to accept multiple build modes in one build and generate separate objects, libraries and executables for each mode.
Removed deferred negation optimization (a * -b => -(a * b)) since this visibly changes operand conversion order.
Improved parsing performance by introducing stack guard in preparsing. Without a stack guard preparsing always bails out with stack overflow.
Changed shell sample to take flags directly from the command-line. Added API call that implements this.
Added load, quit and version functions to the shell sample so it's easier to run benchmarks and tests.
Fixed issue with building samples and cctests on 64-bit machines.
Fixed bug in the runtime system where the prototype chain was not always searched for a setter when setting a property that does not exist locally.
git-svn-id: http://v8.googlecode.com/svn/trunk@60 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/factory.cc b/src/factory.cc
index ba7dc3c..8016965 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -172,6 +172,11 @@
}
+Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) {
+ CALL_HEAP_FUNCTION(src->CopyDropTransitions(), Map);
+}
+
+
Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
CALL_HEAP_FUNCTION(array->Copy(), FixedArray);
}
@@ -198,12 +203,21 @@
Handle<JSFunction> result =
BaseNewFunctionFromBoilerplate(boilerplate, Top::function_map());
result->set_context(*context);
- int number_of_literals = boilerplate->literals()->length();
+ int number_of_literals = boilerplate->NumberOfLiterals();
+ Handle<FixedArray> literals =
+ Factory::NewFixedArray(number_of_literals, TENURED);
if (number_of_literals > 0) {
- Handle<FixedArray> literals =
- Factory::NewFixedArray(number_of_literals, TENURED);
- result->set_literals(*literals);
+ // Store the object, regexp and array functions in the literals
+ // array prefix. These functions will be used when creating
+ // object, regexp and array literals in this function.
+ literals->set(JSFunction::kLiteralObjectFunctionIndex,
+ context->global_context()->object_function());
+ literals->set(JSFunction::kLiteralRegExpFunctionIndex,
+ context->global_context()->regexp_function());
+ literals->set(JSFunction::kLiteralArrayFunctionIndex,
+ context->global_context()->array_function());
}
+ result->set_literals(*literals);
ASSERT(!result->IsBoilerplate());
return result;
}
@@ -370,16 +384,20 @@
Handle<JSFunction> Factory::NewFunctionBoilerplate(Handle<String> name,
int number_of_literals,
+ bool contains_array_literal,
Handle<Code> code) {
Handle<JSFunction> function = NewFunctionBoilerplate(name);
function->set_code(*code);
- if (number_of_literals > 0) {
- Handle<FixedArray> literals =
- Factory::NewFixedArray(number_of_literals, TENURED);
- function->set_literals(*literals);
- } else {
- function->set_literals(Heap::empty_fixed_array());
+ int literals_array_size = number_of_literals;
+ // If the function contains object, regexp or array literals,
+ // allocate extra space for a literals array prefix containing the
+ // object, regexp and array constructor functions.
+ if (number_of_literals > 0 || contains_array_literal) {
+ literals_array_size += JSFunction::kLiteralsPrefixSize;
}
+ Handle<FixedArray> literals =
+ Factory::NewFixedArray(literals_array_size, TENURED);
+ function->set_literals(*literals);
ASSERT(!function->has_initial_map());
ASSERT(!function->has_prototype());
return function;
@@ -451,11 +469,11 @@
PropertyAttributes attributes) {
GC_GREEDY_CHECK();
CallbacksDescriptor desc(*key, *value, attributes);
- Object* obj = array->CopyInsert(&desc);
+ Object* obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS);
if (obj->IsRetryAfterGC()) {
CALL_GC(obj);
CallbacksDescriptor desc(*key, *value, attributes);
- obj = array->CopyInsert(&desc);
+ obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS);
if (obj->IsFailure()) {
// TODO(1181417): Fix this.
V8::FatalProcessOutOfMemory("CopyAppendProxyDescriptor");
@@ -542,8 +560,7 @@
Handle<JSObject> Factory::NewObjectLiteral(int expected_number_of_properties) {
Handle<Map> map = Handle<Map>(Top::object_function()->initial_map());
map = Factory::CopyMap(map);
- map->set_instance_descriptors(
- DescriptorArray::cast(Heap::empty_fixed_array()));
+ map->set_instance_descriptors(Heap::empty_descriptor_array());
map->set_unused_property_fields(expected_number_of_properties);
CALL_HEAP_FUNCTION(Heap::AllocateJSObjectFromMap(*map, TENURED),
JSObject);
@@ -691,7 +708,7 @@
if (parent->IsUndefined()) break;
obj = Handle<FunctionTemplateInfo>::cast(parent);
}
- if (array->length() > 0) {
+ if (!array->IsEmpty()) {
map->set_instance_descriptors(*array);
}