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

Side by Side Diff: src/contexts.h

Issue 954693003: [strong] Make functions and generators non-extensible non-constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/bootstrapper.cc ('k') | test/mjsunit/strong/functions.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_CONTEXTS_H_ 5 #ifndef V8_CONTEXTS_H_
6 #define V8_CONTEXTS_H_ 6 #define V8_CONTEXTS_H_
7 7
8 #include "src/heap/heap.h" 8 #include "src/heap/heap.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 V(UINT32_ARRAY_EXTERNAL_MAP_INDEX, Map, uint32_array_external_map) \ 118 V(UINT32_ARRAY_EXTERNAL_MAP_INDEX, Map, uint32_array_external_map) \
119 V(FLOAT32_ARRAY_EXTERNAL_MAP_INDEX, Map, float32_array_external_map) \ 119 V(FLOAT32_ARRAY_EXTERNAL_MAP_INDEX, Map, float32_array_external_map) \
120 V(FLOAT64_ARRAY_EXTERNAL_MAP_INDEX, Map, float64_array_external_map) \ 120 V(FLOAT64_ARRAY_EXTERNAL_MAP_INDEX, Map, float64_array_external_map) \
121 V(UINT8_CLAMPED_ARRAY_EXTERNAL_MAP_INDEX, Map, \ 121 V(UINT8_CLAMPED_ARRAY_EXTERNAL_MAP_INDEX, Map, \
122 uint8_clamped_array_external_map) \ 122 uint8_clamped_array_external_map) \
123 V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \ 123 V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \
124 V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map) \ 124 V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map) \
125 V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \ 125 V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \
126 sloppy_function_with_readonly_prototype_map) \ 126 sloppy_function_with_readonly_prototype_map) \
127 V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \ 127 V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \
128 V(STRONG_FUNCTION_MAP_INDEX, Map, strong_function_map) \
128 V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ 129 V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
129 sloppy_function_without_prototype_map) \ 130 sloppy_function_without_prototype_map) \
130 V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ 131 V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
131 strict_function_without_prototype_map) \ 132 strict_function_without_prototype_map) \
133 V(STRONG_CONSTRUCTOR_MAP_INDEX, Map, strong_constructor_map) \
132 V(BOUND_FUNCTION_MAP_INDEX, Map, bound_function_map) \ 134 V(BOUND_FUNCTION_MAP_INDEX, Map, bound_function_map) \
133 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map) \ 135 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map) \
134 V(SLOPPY_ARGUMENTS_MAP_INDEX, Map, sloppy_arguments_map) \ 136 V(SLOPPY_ARGUMENTS_MAP_INDEX, Map, sloppy_arguments_map) \
135 V(ALIASED_ARGUMENTS_MAP_INDEX, Map, aliased_arguments_map) \ 137 V(ALIASED_ARGUMENTS_MAP_INDEX, Map, aliased_arguments_map) \
136 V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \ 138 V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \
137 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \ 139 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \
138 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \ 140 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \
139 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \ 141 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \
140 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \ 142 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \
141 V(FUNCTION_CACHE_INDEX, FixedArray, function_cache) \ 143 V(FUNCTION_CACHE_INDEX, FixedArray, function_cache) \
(...skipping 27 matching lines...) Expand all
169 V(OBSERVERS_NOTIFY_CHANGE_INDEX, JSFunction, observers_notify_change) \ 171 V(OBSERVERS_NOTIFY_CHANGE_INDEX, JSFunction, observers_notify_change) \
170 V(OBSERVERS_ENQUEUE_SPLICE_INDEX, JSFunction, observers_enqueue_splice) \ 172 V(OBSERVERS_ENQUEUE_SPLICE_INDEX, JSFunction, observers_enqueue_splice) \
171 V(OBSERVERS_BEGIN_SPLICE_INDEX, JSFunction, observers_begin_perform_splice) \ 173 V(OBSERVERS_BEGIN_SPLICE_INDEX, JSFunction, observers_begin_perform_splice) \
172 V(OBSERVERS_END_SPLICE_INDEX, JSFunction, observers_end_perform_splice) \ 174 V(OBSERVERS_END_SPLICE_INDEX, JSFunction, observers_end_perform_splice) \
173 V(NATIVE_OBJECT_OBSERVE_INDEX, JSFunction, native_object_observe) \ 175 V(NATIVE_OBJECT_OBSERVE_INDEX, JSFunction, native_object_observe) \
174 V(NATIVE_OBJECT_GET_NOTIFIER_INDEX, JSFunction, native_object_get_notifier) \ 176 V(NATIVE_OBJECT_GET_NOTIFIER_INDEX, JSFunction, native_object_get_notifier) \
175 V(NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, JSFunction, \ 177 V(NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, JSFunction, \
176 native_object_notifier_perform_change) \ 178 native_object_notifier_perform_change) \
177 V(SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, Map, sloppy_generator_function_map) \ 179 V(SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, Map, sloppy_generator_function_map) \
178 V(STRICT_GENERATOR_FUNCTION_MAP_INDEX, Map, strict_generator_function_map) \ 180 V(STRICT_GENERATOR_FUNCTION_MAP_INDEX, Map, strict_generator_function_map) \
181 V(STRONG_GENERATOR_FUNCTION_MAP_INDEX, Map, strong_generator_function_map) \
179 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \ 182 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \
180 V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \ 183 V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \
181 V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \ 184 V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \
182 V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \ 185 V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \
183 V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ 186 V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \
184 V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) 187 V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table)
185 188
186 189
187 // A table of all script contexts. Every loaded top-level script with top-level 190 // A table of all script contexts. Every loaded top-level script with top-level
188 // lexical declarations contributes its ScriptContext into this table. 191 // lexical declarations contributes its ScriptContext into this table.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // These slots are only in native contexts. 315 // These slots are only in native contexts.
313 GLOBAL_PROXY_INDEX = MIN_CONTEXT_SLOTS, 316 GLOBAL_PROXY_INDEX = MIN_CONTEXT_SLOTS,
314 SECURITY_TOKEN_INDEX, 317 SECURITY_TOKEN_INDEX,
315 SLOPPY_ARGUMENTS_MAP_INDEX, 318 SLOPPY_ARGUMENTS_MAP_INDEX,
316 ALIASED_ARGUMENTS_MAP_INDEX, 319 ALIASED_ARGUMENTS_MAP_INDEX,
317 STRICT_ARGUMENTS_MAP_INDEX, 320 STRICT_ARGUMENTS_MAP_INDEX,
318 REGEXP_RESULT_MAP_INDEX, 321 REGEXP_RESULT_MAP_INDEX,
319 SLOPPY_FUNCTION_MAP_INDEX, 322 SLOPPY_FUNCTION_MAP_INDEX,
320 SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, 323 SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX,
321 STRICT_FUNCTION_MAP_INDEX, 324 STRICT_FUNCTION_MAP_INDEX,
325 STRONG_FUNCTION_MAP_INDEX,
322 SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, 326 SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
323 STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, 327 STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
328 STRONG_CONSTRUCTOR_MAP_INDEX,
324 BOUND_FUNCTION_MAP_INDEX, 329 BOUND_FUNCTION_MAP_INDEX,
325 INITIAL_OBJECT_PROTOTYPE_INDEX, 330 INITIAL_OBJECT_PROTOTYPE_INDEX,
326 INITIAL_ARRAY_PROTOTYPE_INDEX, 331 INITIAL_ARRAY_PROTOTYPE_INDEX,
327 BOOLEAN_FUNCTION_INDEX, 332 BOOLEAN_FUNCTION_INDEX,
328 NUMBER_FUNCTION_INDEX, 333 NUMBER_FUNCTION_INDEX,
329 STRING_FUNCTION_INDEX, 334 STRING_FUNCTION_INDEX,
330 STRING_FUNCTION_PROTOTYPE_MAP_INDEX, 335 STRING_FUNCTION_PROTOTYPE_MAP_INDEX,
331 SYMBOL_FUNCTION_INDEX, 336 SYMBOL_FUNCTION_INDEX,
332 OBJECT_FUNCTION_INDEX, 337 OBJECT_FUNCTION_INDEX,
333 INTERNAL_ARRAY_FUNCTION_INDEX, 338 INTERNAL_ARRAY_FUNCTION_INDEX,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 PROXY_ENUMERATE_INDEX, 404 PROXY_ENUMERATE_INDEX,
400 OBSERVERS_NOTIFY_CHANGE_INDEX, 405 OBSERVERS_NOTIFY_CHANGE_INDEX,
401 OBSERVERS_ENQUEUE_SPLICE_INDEX, 406 OBSERVERS_ENQUEUE_SPLICE_INDEX,
402 OBSERVERS_BEGIN_SPLICE_INDEX, 407 OBSERVERS_BEGIN_SPLICE_INDEX,
403 OBSERVERS_END_SPLICE_INDEX, 408 OBSERVERS_END_SPLICE_INDEX,
404 NATIVE_OBJECT_OBSERVE_INDEX, 409 NATIVE_OBJECT_OBSERVE_INDEX,
405 NATIVE_OBJECT_GET_NOTIFIER_INDEX, 410 NATIVE_OBJECT_GET_NOTIFIER_INDEX,
406 NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, 411 NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE,
407 SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, 412 SLOPPY_GENERATOR_FUNCTION_MAP_INDEX,
408 STRICT_GENERATOR_FUNCTION_MAP_INDEX, 413 STRICT_GENERATOR_FUNCTION_MAP_INDEX,
414 STRONG_GENERATOR_FUNCTION_MAP_INDEX,
409 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, 415 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX,
410 ITERATOR_RESULT_MAP_INDEX, 416 ITERATOR_RESULT_MAP_INDEX,
411 MAP_ITERATOR_MAP_INDEX, 417 MAP_ITERATOR_MAP_INDEX,
412 SET_ITERATOR_MAP_INDEX, 418 SET_ITERATOR_MAP_INDEX,
413 ARRAY_VALUES_ITERATOR_INDEX, 419 ARRAY_VALUES_ITERATOR_INDEX,
414 SCRIPT_CONTEXT_TABLE_INDEX, 420 SCRIPT_CONTEXT_TABLE_INDEX,
415 MAP_CACHE_INDEX, 421 MAP_CACHE_INDEX,
416 TO_LENGTH_FUN_INDEX, 422 TO_LENGTH_FUN_INDEX,
417 423
418 // Properties from here are treated as weak references by the full GC. 424 // Properties from here are treated as weak references by the full GC.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 PropertyAttributes* attributes, 569 PropertyAttributes* attributes,
564 BindingFlags* binding_flags); 570 BindingFlags* binding_flags);
565 571
566 // Code generation support. 572 // Code generation support.
567 static int SlotOffset(int index) { 573 static int SlotOffset(int index) {
568 return kHeaderSize + index * kPointerSize - kHeapObjectTag; 574 return kHeaderSize + index * kPointerSize - kHeapObjectTag;
569 } 575 }
570 576
571 static int FunctionMapIndex(LanguageMode language_mode, FunctionKind kind) { 577 static int FunctionMapIndex(LanguageMode language_mode, FunctionKind kind) {
572 if (IsGeneratorFunction(kind)) { 578 if (IsGeneratorFunction(kind)) {
573 return is_strict(language_mode) ? STRICT_GENERATOR_FUNCTION_MAP_INDEX 579 return is_strong(language_mode) ? STRONG_GENERATOR_FUNCTION_MAP_INDEX :
580 is_strict(language_mode) ? STRICT_GENERATOR_FUNCTION_MAP_INDEX
574 : SLOPPY_GENERATOR_FUNCTION_MAP_INDEX; 581 : SLOPPY_GENERATOR_FUNCTION_MAP_INDEX;
575 } 582 }
576 583
584 if (IsConstructor(kind)) {
585 return is_strong(language_mode) ? STRONG_CONSTRUCTOR_MAP_INDEX :
586 is_strict(language_mode) ? STRICT_FUNCTION_MAP_INDEX
587 : SLOPPY_FUNCTION_MAP_INDEX;
588 }
589
577 if (IsArrowFunction(kind) || IsConciseMethod(kind) || 590 if (IsArrowFunction(kind) || IsConciseMethod(kind) ||
578 IsAccessorFunction(kind)) { 591 IsAccessorFunction(kind)) {
579 return is_strict(language_mode) 592 return is_strong(language_mode) ? STRONG_FUNCTION_MAP_INDEX :
580 ? STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX 593 is_strict(language_mode) ?
581 : SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX; 594 STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX :
595 SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX;
582 } 596 }
583 597
584 return is_strict(language_mode) ? STRICT_FUNCTION_MAP_INDEX 598 return is_strong(language_mode) ? STRONG_FUNCTION_MAP_INDEX :
599 is_strict(language_mode) ? STRICT_FUNCTION_MAP_INDEX
585 : SLOPPY_FUNCTION_MAP_INDEX; 600 : SLOPPY_FUNCTION_MAP_INDEX;
586 } 601 }
587 602
588 static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize; 603 static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize;
589 604
590 // GC support. 605 // GC support.
591 typedef FixedBodyDescriptor< 606 typedef FixedBodyDescriptor<
592 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; 607 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor;
593 608
594 typedef FixedBodyDescriptor< 609 typedef FixedBodyDescriptor<
(...skipping 11 matching lines...) Expand all
606 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object); 621 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object);
607 #endif 622 #endif
608 623
609 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); 624 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize);
610 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); 625 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex);
611 }; 626 };
612 627
613 } } // namespace v8::internal 628 } } // namespace v8::internal
614 629
615 #endif // V8_CONTEXTS_H_ 630 #endif // V8_CONTEXTS_H_
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | test/mjsunit/strong/functions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698