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

Side by Side Diff: src/objects-inl.h

Issue 8199004: Reimplement Function.prototype.bind. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 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 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 return reinterpret_cast<FixedArray*>( 3304 return reinterpret_cast<FixedArray*>(
3305 READ_FIELD(this, kPrototypeTransitionsOffset)); 3305 READ_FIELD(this, kPrototypeTransitionsOffset));
3306 } 3306 }
3307 3307
3308 3308
3309 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) 3309 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset)
3310 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) 3310 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset)
3311 ACCESSORS(Map, constructor, Object, kConstructorOffset) 3311 ACCESSORS(Map, constructor, Object, kConstructorOffset)
3312 3312
3313 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) 3313 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
3314 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) 3314 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset)
3315 ACCESSORS(JSFunction, 3315 ACCESSORS(JSFunction,
3316 next_function_link, 3316 next_function_link,
3317 Object, 3317 Object,
3318 kNextFunctionLinkOffset) 3318 kNextFunctionLinkOffset)
3319 3319
3320 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) 3320 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset)
3321 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) 3321 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset)
3322 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) 3322 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset)
3323 3323
3324 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) 3324 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset)
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3823 bool JSFunction::should_have_prototype() { 3823 bool JSFunction::should_have_prototype() {
3824 return map()->function_with_prototype(); 3824 return map()->function_with_prototype();
3825 } 3825 }
3826 3826
3827 3827
3828 bool JSFunction::is_compiled() { 3828 bool JSFunction::is_compiled() {
3829 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile); 3829 return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile);
3830 } 3830 }
3831 3831
3832 3832
3833 FixedArray* JSFunction::literals() {
3834 ASSERT(!shared()->bound());
3835 return literals_or_bindings();
3836 }
3837
3838
3839 void JSFunction::set_literals(FixedArray* literals) {
3840 ASSERT(!shared()->bound());
3841 set_literals_or_bindings(literals);
3842 }
3843
3844
3845 FixedArray* JSFunction::function_bindings() {
3846 ASSERT(shared()->bound());
3847 return literals_or_bindings();
3848 }
3849
3850
3851 void JSFunction::set_function_bindings(FixedArray* bindings) {
3852 ASSERT(shared()->bound());
3853 // Bound function literal may be initialized to the empty fixed array
3854 // before the bindings are set.
3855 ASSERT(bindings == GetHeap()->empty_fixed_array() ||
3856 bindings->map() == GetHeap()->fixed_cow_array_map());
3857 set_literals_or_bindings(bindings);
3858 }
3859
3860
3833 int JSFunction::NumberOfLiterals() { 3861 int JSFunction::NumberOfLiterals() {
3862 ASSERT(!shared()->bound());
3834 return literals()->length(); 3863 return literals()->length();
3835 } 3864 }
3836 3865
3837 3866
3838 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { 3867 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) {
3839 ASSERT(id < kJSBuiltinsCount); // id is unsigned. 3868 ASSERT(id < kJSBuiltinsCount); // id is unsigned.
3840 return READ_FIELD(this, OffsetOfFunctionWithId(id)); 3869 return READ_FIELD(this, OffsetOfFunctionWithId(id));
3841 } 3870 }
3842 3871
3843 3872
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 #undef WRITE_INT_FIELD 4670 #undef WRITE_INT_FIELD
4642 #undef READ_SHORT_FIELD 4671 #undef READ_SHORT_FIELD
4643 #undef WRITE_SHORT_FIELD 4672 #undef WRITE_SHORT_FIELD
4644 #undef READ_BYTE_FIELD 4673 #undef READ_BYTE_FIELD
4645 #undef WRITE_BYTE_FIELD 4674 #undef WRITE_BYTE_FIELD
4646 4675
4647 4676
4648 } } // namespace v8::internal 4677 } } // namespace v8::internal
4649 4678
4650 #endif // V8_OBJECTS_INL_H_ 4679 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698