Commit 30ecaa2f authored by rossberg@chromium.org's avatar rossberg@chromium.org

Move derived get trap from builtins to global context.

Review URL: http://codereview.chromium.org/7017008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7936 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 12350099
......@@ -199,6 +199,7 @@ class Genesis BASE_EMBEDDED {
// Installs the contents of the native .js files on the global objects.
// Used for creating a context from scratch.
void InstallNativeFunctions();
void InstallExperimentalNativeFunctions();
bool InstallNatives();
bool InstallExperimentalNatives();
void InstallBuiltinFunctionIds();
......@@ -1285,6 +1286,12 @@ void Genesis::InstallNativeFunctions() {
INSTALL_NATIVE(JSObject, "functionCache", function_cache);
}
void Genesis::InstallExperimentalNativeFunctions() {
if (FLAG_harmony_proxies) {
INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
}
}
#undef INSTALL_NATIVE
......@@ -1647,6 +1654,9 @@ bool Genesis::InstallExperimentalNatives() {
if (!CompileExperimentalBuiltin(isolate(), i)) return false;
}
}
InstallExperimentalNativeFunctions();
return true;
}
......
......@@ -244,8 +244,7 @@ enum BuiltinExtraArguments {
V(STRING_ADD_LEFT, 1) \
V(STRING_ADD_RIGHT, 1) \
V(APPLY_PREPARE, 1) \
V(APPLY_OVERFLOW, 1) \
V(DERIVED_GET_TRAP, 2)
V(APPLY_OVERFLOW, 1)
class BuiltinFunctionTable;
......
......@@ -107,7 +107,8 @@ enum ContextLookupFlags {
V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \
V(MAP_CACHE_INDEX, Object, map_cache) \
V(CONTEXT_DATA_INDEX, Object, data) \
V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings)
V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \
V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap)
// JSFunctions are pairs (context, function code), sometimes also called
// closures. A Context object is used to represent function contexts and
......@@ -238,6 +239,7 @@ class Context: public FixedArray {
MAP_CACHE_INDEX,
CONTEXT_DATA_INDEX,
ALLOW_CODE_GEN_FROM_STRINGS_INDEX,
DERIVED_GET_TRAP_INDEX,
// Properties from here are treated as weak references by the full GC.
// Scavenge treats them as strong references.
......
......@@ -239,9 +239,7 @@ MaybeObject* Object::GetPropertyWithHandler(Object* receiver_raw,
Handle<Object> trap(v8::internal::GetProperty(handler, "get", &lookup));
if (!lookup.IsFound()) {
// Get the derived `get' property.
Object* derived = isolate->global_context()->builtins()->javascript_builtin(
Builtins::DERIVED_GET_TRAP);
trap = Handle<JSFunction>(JSFunction::cast(derived));
trap = isolate->derived_get_trap();
}
// Call trap function.
......
......@@ -63,3 +63,21 @@ $Proxy.create = function(handler, proto) {
if (!IS_SPEC_OBJECT(proto)) proto = $Object.prototype
return %CreateJSProxy(handler, proto)
}
////////////////////////////////////////////////////////////////////////////////
// Builtins
////////////////////////////////////////////////////////////////////////////////
function DerivedGetTrap(receiver, name) {
var desc = this.getPropertyDescriptor(name)
if (IS_UNDEFINED(desc)) { return desc; }
if ('value' in desc) {
return desc.value
} else {
if (IS_UNDEFINED(desc.get)) { return desc.get; }
return desc.get.call(receiver) // The proposal says so...
}
}
......@@ -647,20 +647,3 @@ function DefaultString(x) {
// that is cloned when running the code. It is essential that the
// boilerplate gets the right prototype.
%FunctionSetPrototype($Array, new $Array(0));
/* ------------------------------------------
- - - H a r m o n y P r o x i e s - - -
---------------------------------------------
*/
function DERIVED_GET_TRAP(receiver, name) {
var desc = this.getPropertyDescriptor(name);
if (IS_UNDEFINED(desc)) { return desc; }
if ('value' in desc) {
return desc.value;
} else {
if (IS_UNDEFINED(desc.get)) { return desc.get; }
return desc.get().call(receiver); // The proposal says so...
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment