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

Side by Side Diff: src/runtime.cc

Issue 7475002: Ensure that the length property of bound functions are actual unique (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 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
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 NoHandleAllocation ha; 1959 NoHandleAllocation ha;
1960 ASSERT(args.length() == 2); 1960 ASSERT(args.length() == 2);
1961 1961
1962 CONVERT_CHECKED(JSFunction, fun, args[0]); 1962 CONVERT_CHECKED(JSFunction, fun, args[0]);
1963 CONVERT_CHECKED(Smi, length, args[1]); 1963 CONVERT_CHECKED(Smi, length, args[1]);
1964 fun->shared()->set_length(length->value()); 1964 fun->shared()->set_length(length->value());
1965 return length; 1965 return length;
1966 } 1966 }
1967 1967
1968 1968
1969 // Creates a local, readonly, property called length with the correct
1970 // length (when read by the user). This effectively overwrites the
1971 // interceptor used to normally provide the length.
1972 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionSetLength) {
1973 NoHandleAllocation ha;
1974 ASSERT(args.length() == 2);
1975 CONVERT_CHECKED(JSFunction, fun, args[0]);
1976 CONVERT_CHECKED(Smi, length, args[1]);
1977 MaybeObject* maybe_name =
1978 isolate->heap()->AllocateStringFromAscii(CStrVector("length"));
1979 String* name;
1980 if (!maybe_name->To(&name)) return maybe_name;
1981 PropertyAttributes attr =
1982 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY);
1983 return fun->AddProperty(name, length, attr, kNonStrictMode);
1984 }
1985
1986
1969 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { 1987 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) {
1970 NoHandleAllocation ha; 1988 NoHandleAllocation ha;
1971 ASSERT(args.length() == 2); 1989 ASSERT(args.length() == 2);
1972 1990
1973 CONVERT_CHECKED(JSFunction, fun, args[0]); 1991 CONVERT_CHECKED(JSFunction, fun, args[0]);
1974 ASSERT(fun->should_have_prototype()); 1992 ASSERT(fun->should_have_prototype());
1975 Object* obj; 1993 Object* obj;
1976 { MaybeObject* maybe_obj = 1994 { MaybeObject* maybe_obj =
1977 Accessors::FunctionSetPrototype(fun, args[1], NULL); 1995 Accessors::FunctionSetPrototype(fun, args[1], NULL);
1978 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1996 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
(...skipping 10787 matching lines...) Expand 10 before | Expand all | Expand 10 after
12766 } else { 12784 } else {
12767 // Handle last resort GC and make sure to allow future allocations 12785 // Handle last resort GC and make sure to allow future allocations
12768 // to grow the heap without causing GCs (if possible). 12786 // to grow the heap without causing GCs (if possible).
12769 isolate->counters()->gc_last_resort_from_js()->Increment(); 12787 isolate->counters()->gc_last_resort_from_js()->Increment();
12770 isolate->heap()->CollectAllGarbage(false); 12788 isolate->heap()->CollectAllGarbage(false);
12771 } 12789 }
12772 } 12790 }
12773 12791
12774 12792
12775 } } // namespace v8::internal 12793 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698