Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: src/runtime.cc

Issue 22903012: js accessor creation on Template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 MaybeObject* maybe_new_map = old_map->Copy(); 1937 MaybeObject* maybe_new_map = old_map->Copy();
1938 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 1938 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
1939 1939
1940 new_map->set_is_access_check_needed(true); 1940 new_map->set_is_access_check_needed(true);
1941 object->set_map(new_map); 1941 object->set_map(new_map);
1942 } 1942 }
1943 return isolate->heap()->undefined_value(); 1943 return isolate->heap()->undefined_value();
1944 } 1944 }
1945 1945
1946 1946
1947 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineJsAccessor) {
1948 HandleScope scope(isolate);
1949 ASSERT(args.length() == 3);
1950 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
1951 CONVERT_ARG_HANDLE_CHECKED(Object, array_object, 1);
1952 CONVERT_SMI_ARG_CHECKED(offset, 2);
1953 // Order of array contents is determined in Template::SetAccessor.
1954 NeanderArray array(array_object);
1955 Handle<String> name(String::cast(array.get(offset++)), isolate);
1956 Handle<Object> getter(array.get(offset++), isolate);
1957 Handle<Object> setter(array.get(offset++), isolate);
1958 v8::AccessControl access_control =
1959 static_cast<v8::AccessControl>(Smi::cast(array.get(offset++))->value());
1960 PropertyAttributes attributes =
1961 static_cast<PropertyAttributes>(Smi::cast(array.get(offset++))->value());
1962 // Transform getter into something DefineAccessor can handle.
1963 if (getter->IsUndefined()) {
1964 getter = isolate->factory()->null_value();
1965 } else {
1966 Handle<FunctionTemplateInfo> info =
1967 Handle<FunctionTemplateInfo>::cast(getter);
1968 getter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
1969 }
1970 // Transform getter into something DefineAccessor can handle.
1971 if (setter->IsUndefined()) {
1972 setter = isolate->factory()->null_value();
1973 } else {
1974 Handle<FunctionTemplateInfo> info =
1975 Handle<FunctionTemplateInfo>::cast(setter);
1976 setter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
1977 }
1978 JSObject::DefineAccessor(
1979 object, name, getter, setter, attributes, access_control);
1980 return isolate->heap()->undefined_value();
1981 }
1982
1983
1947 static Failure* ThrowRedeclarationError(Isolate* isolate, 1984 static Failure* ThrowRedeclarationError(Isolate* isolate,
1948 const char* type, 1985 const char* type,
1949 Handle<String> name) { 1986 Handle<String> name) {
1950 HandleScope scope(isolate); 1987 HandleScope scope(isolate);
1951 Handle<Object> type_handle = 1988 Handle<Object> type_handle =
1952 isolate->factory()->NewStringFromAscii(CStrVector(type)); 1989 isolate->factory()->NewStringFromAscii(CStrVector(type));
1953 Handle<Object> args[2] = { type_handle, name }; 1990 Handle<Object> args[2] = { type_handle, name };
1954 Handle<Object> error = 1991 Handle<Object> error =
1955 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); 1992 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2));
1956 return isolate->Throw(*error); 1993 return isolate->Throw(*error);
(...skipping 12534 matching lines...) Expand 10 before | Expand all | Expand 10 after
14491 // Handle last resort GC and make sure to allow future allocations 14528 // Handle last resort GC and make sure to allow future allocations
14492 // to grow the heap without causing GCs (if possible). 14529 // to grow the heap without causing GCs (if possible).
14493 isolate->counters()->gc_last_resort_from_js()->Increment(); 14530 isolate->counters()->gc_last_resort_from_js()->Increment();
14494 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14531 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14495 "Runtime::PerformGC"); 14532 "Runtime::PerformGC");
14496 } 14533 }
14497 } 14534 }
14498 14535
14499 14536
14500 } } // namespace v8::internal 14537 } } // namespace v8::internal
OLDNEW
« src/objects-inl.h ('K') | « src/runtime.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698