Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/elements.h" | 10 #include "src/elements.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 prototype->set_elements(isolate->heap()->empty_fixed_array()); | 30 prototype->set_elements(isolate->heap()->empty_fixed_array()); |
| 31 return Smi::kZero; | 31 return Smi::kZero; |
| 32 } | 32 } |
| 33 | 33 |
| 34 static void InstallCode( | 34 static void InstallCode( |
| 35 Isolate* isolate, Handle<JSObject> holder, const char* name, | 35 Isolate* isolate, Handle<JSObject> holder, const char* name, |
| 36 Handle<Code> code, int argc = -1, | 36 Handle<Code> code, int argc = -1, |
| 37 BuiltinFunctionId id = static_cast<BuiltinFunctionId>(-1)) { | 37 BuiltinFunctionId id = static_cast<BuiltinFunctionId>(-1)) { |
| 38 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); | 38 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); |
| 39 Handle<JSFunction> optimized = | 39 Handle<JSFunction> optimized = |
| 40 isolate->factory()->NewFunctionWithoutPrototype(key, code); | 40 isolate->factory()->NewFunctionWithoutPrototype(key, code, true); |
| 41 if (argc < 0) { | 41 if (argc < 0) { |
| 42 optimized->shared()->DontAdaptArguments(); | 42 optimized->shared()->DontAdaptArguments(); |
| 43 } else { | 43 } else { |
| 44 optimized->shared()->set_internal_formal_parameter_count(argc); | 44 optimized->shared()->set_internal_formal_parameter_count(argc); |
| 45 } | 45 } |
| 46 if (id >= 0) { | 46 if (id >= 0) { |
| 47 optimized->shared()->set_builtin_function_id(id); | 47 optimized->shared()->set_builtin_function_id(id); |
| 48 } | 48 } |
| 49 optimized->shared()->set_language_mode(STRICT); | |
| 50 optimized->shared()->set_native(true); | |
| 49 JSObject::AddProperty(holder, key, optimized, NONE); | 51 JSObject::AddProperty(holder, key, optimized, NONE); |
| 50 } | 52 } |
| 51 | 53 |
| 52 static void InstallBuiltin( | 54 static void InstallBuiltin( |
| 53 Isolate* isolate, Handle<JSObject> holder, const char* name, | 55 Isolate* isolate, Handle<JSObject> holder, const char* name, |
| 54 Builtins::Name builtin_name, int argc = -1, | 56 Builtins::Name builtin_name, int argc = -1, |
| 55 BuiltinFunctionId id = static_cast<BuiltinFunctionId>(-1)) { | 57 BuiltinFunctionId id = static_cast<BuiltinFunctionId>(-1)) { |
| 56 InstallCode(isolate, holder, name, | 58 InstallCode(isolate, holder, name, |
| 57 handle(isolate->builtins()->builtin(builtin_name), isolate), argc, | 59 handle(isolate->builtins()->builtin(builtin_name), isolate), argc, |
| 58 id); | 60 id); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 71 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 73 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
| 72 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 74 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
| 73 InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes, 2); | 75 InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes, 2); |
| 74 InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf, 2); | 76 InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf, 2); |
| 75 InstallBuiltin(isolate, holder, "keys", Builtins::kArrayPrototypeKeys, 0, | 77 InstallBuiltin(isolate, holder, "keys", Builtins::kArrayPrototypeKeys, 0, |
| 76 kArrayKeys); | 78 kArrayKeys); |
| 77 InstallBuiltin(isolate, holder, "values", Builtins::kArrayPrototypeValues, 0, | 79 InstallBuiltin(isolate, holder, "values", Builtins::kArrayPrototypeValues, 0, |
| 78 kArrayValues); | 80 kArrayValues); |
| 79 InstallBuiltin(isolate, holder, "entries", Builtins::kArrayPrototypeEntries, | 81 InstallBuiltin(isolate, holder, "entries", Builtins::kArrayPrototypeEntries, |
| 80 0, kArrayEntries); | 82 0, kArrayEntries); |
| 81 | |
| 82 return *holder; | 83 return *holder; |
| 83 } | 84 } |
| 84 | 85 |
| 86 RUNTIME_FUNCTION(Runtime_SpecialExperimentalArrayFunctions) { | |
|
Yang
2017/02/03 10:20:25
This is no longer necessary, is it?
danno
2017/02/03 12:46:55
Done.
| |
| 87 HandleScope scope(isolate); | |
| 88 DCHECK_EQ(0, args.length()); | |
| 89 Handle<JSObject> holder = | |
| 90 isolate->factory()->NewJSObject(isolate->object_function()); | |
| 91 if (FLAG_enable_fast_array_builtins) { | |
| 92 InstallBuiltin(isolate, holder, "forEach", Builtins::kArrayForEach, | |
| 93 ForEachDescriptor::kStackParameterCount); | |
| 94 } | |
| 95 return *holder; | |
| 96 } | |
| 85 | 97 |
| 86 RUNTIME_FUNCTION(Runtime_FixedArrayGet) { | 98 RUNTIME_FUNCTION(Runtime_FixedArrayGet) { |
| 87 SealHandleScope shs(isolate); | 99 SealHandleScope shs(isolate); |
| 88 DCHECK_EQ(2, args.length()); | 100 DCHECK_EQ(2, args.length()); |
| 89 CONVERT_ARG_CHECKED(FixedArray, object, 0); | 101 CONVERT_ARG_CHECKED(FixedArray, object, 0); |
| 90 CONVERT_SMI_ARG_CHECKED(index, 1); | 102 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 91 return object->get(index); | 103 return object->get(index); |
| 92 } | 104 } |
| 93 | 105 |
| 94 | 106 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 DCHECK(accessor->HasElement(spread_array, i)); | 681 DCHECK(accessor->HasElement(spread_array, i)); |
| 670 Handle<Object> element = accessor->Get(spread_array, i); | 682 Handle<Object> element = accessor->Get(spread_array, i); |
| 671 result->set(i, *element); | 683 result->set(i, *element); |
| 672 } | 684 } |
| 673 | 685 |
| 674 return *result; | 686 return *result; |
| 675 } | 687 } |
| 676 | 688 |
| 677 } // namespace internal | 689 } // namespace internal |
| 678 } // namespace v8 | 690 } // namespace v8 |
| OLD | NEW |