Split the global object into two parts: The state holding global object and the global object proxy.
Fixed bug that affected the value of an assignment to an element in certain cases (issue 116).
Added GetPropertyNames functionality (issue 33) and extra Date functions (issue 77) to the API.
Changed WeakReferenceCallback to take a Persistent<Value> instead of a Persistent<Object> (issue 101).
Fixed issues with message reporting for exceptions in try-finally blocks (issues 73 and 75).
Optimized flattening of strings and string equality checking.
Improved Boyer-Moore implementation for faster indexOf operations.
Added development shell (d8) which includes counters and completion support.
Fixed problem with the receiver passed to functions called from eval (issue 124).
git-svn-id: http://v8.googlecode.com/svn/trunk@572 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/factory.cc b/src/factory.cc
index 2eeb3b9..4e5f5da 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -79,6 +79,8 @@
Handle<String> Factory::NewConsString(Handle<String> first,
Handle<String> second) {
+ if (first->length() == 0) return second;
+ if (second->length() == 0) return first;
CALL_HEAP_FUNCTION(Heap::AllocateConsString(*first, *second), String);
}
@@ -312,7 +314,7 @@
Handle<JSFunction> fun =
Handle<JSFunction>(
JSFunction::cast(
- Top::security_context_builtins()->GetProperty(*make_str)));
+ Top::builtins()->GetProperty(*make_str)));
Handle<Object> type_obj = Factory::LookupAsciiSymbol(type);
Object** argv[2] = { type_obj.location(),
Handle<Object>::cast(args).location() };
@@ -321,7 +323,7 @@
// running the factory method, use the exception as the result.
bool caught_exception;
Handle<Object> result = Execution::TryCall(fun,
- Top::security_context_builtins(),
+ Top::builtins(),
2,
argv,
&caught_exception);
@@ -340,14 +342,14 @@
Handle<JSFunction> fun =
Handle<JSFunction>(
JSFunction::cast(
- Top::security_context_builtins()->GetProperty(*constr)));
+ Top::builtins()->GetProperty(*constr)));
Object** argv[1] = { Handle<Object>::cast(message).location() };
// Invoke the JavaScript factory method. If an exception is thrown while
// running the factory method, use the exception as the result.
bool caught_exception;
Handle<Object> result = Execution::TryCall(fun,
- Top::security_context_builtins(),
+ Top::builtins(),
1,
argv,
&caught_exception);
@@ -670,8 +672,7 @@
Handle<JSFunction> Factory::CreateApiFunction(
- Handle<FunctionTemplateInfo> obj,
- bool is_global) {
+ Handle<FunctionTemplateInfo> obj, ApiInstanceType instance_type) {
Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::HandleApiCall));
int internal_field_count = 0;
@@ -684,14 +685,25 @@
}
int instance_size = kPointerSize * internal_field_count;
- if (is_global) {
- instance_size += JSGlobalObject::kSize;
- } else {
- instance_size += JSObject::kHeaderSize;
+ InstanceType type = JS_OBJECT_TYPE; // initialize to a valid value
+ switch (instance_type) {
+ case JavaScriptObject:
+ type = JS_OBJECT_TYPE;
+ instance_size += JSObject::kHeaderSize;
+ break;
+ case InnerGlobalObject:
+ type = JS_GLOBAL_OBJECT_TYPE;
+ instance_size += JSGlobalObject::kSize;
+ break;
+ case OuterGlobalObject:
+ type = JS_GLOBAL_PROXY_TYPE;
+ instance_size += JSGlobalProxy::kSize;
+ break;
+ default:
+ ASSERT(false);
+ break;
}
- InstanceType type = is_global ? JS_GLOBAL_OBJECT_TYPE : JS_OBJECT_TYPE;
-
Handle<JSFunction> result =
Factory::NewFunction(Factory::empty_symbol(), type, instance_size,
code, true);
@@ -716,7 +728,7 @@
// Mark as needs_access_check if needed.
if (obj->needs_access_check()) {
- map->set_needs_access_check();
+ map->set_is_access_check_needed();
}
// Set interceptor information in the map.