| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 12884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12895 default: | 12895 default: |
| 12896 return false; | 12896 return false; |
| 12897 } | 12897 } |
| 12898 } | 12898 } |
| 12899 | 12899 |
| 12900 } // namespace | 12900 } // namespace |
| 12901 #endif | 12901 #endif |
| 12902 | 12902 |
| 12903 | 12903 |
| 12904 void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) { | 12904 void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) { |
| 12905 DCHECK(function->IsConstructor() || function->shared()->is_resumable()); | 12905 DCHECK(function->IsConstructor() || |
| 12906 IsResumableFunction(function->shared()->kind())); |
| 12906 if (function->has_initial_map()) return; | 12907 if (function->has_initial_map()) return; |
| 12907 Isolate* isolate = function->GetIsolate(); | 12908 Isolate* isolate = function->GetIsolate(); |
| 12908 | 12909 |
| 12909 // The constructor should be compiled for the optimization hints to be | 12910 // The constructor should be compiled for the optimization hints to be |
| 12910 // available. | 12911 // available. |
| 12911 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); | 12912 Compiler::Compile(function, Compiler::CLEAR_EXCEPTION); |
| 12912 | 12913 |
| 12913 // First create a new map with the size and number of in-object properties | 12914 // First create a new map with the size and number of in-object properties |
| 12914 // suggested by the function. | 12915 // suggested by the function. |
| 12915 InstanceType instance_type; | 12916 InstanceType instance_type; |
| 12916 if (function->shared()->is_resumable()) { | 12917 if (IsResumableFunction(function->shared()->kind())) { |
| 12917 instance_type = JS_GENERATOR_OBJECT_TYPE; | 12918 instance_type = JS_GENERATOR_OBJECT_TYPE; |
| 12918 } else { | 12919 } else { |
| 12919 instance_type = JS_OBJECT_TYPE; | 12920 instance_type = JS_OBJECT_TYPE; |
| 12920 } | 12921 } |
| 12921 int instance_size; | 12922 int instance_size; |
| 12922 int in_object_properties; | 12923 int in_object_properties; |
| 12923 function->CalculateInstanceSize(instance_type, 0, &instance_size, | 12924 function->CalculateInstanceSize(instance_type, 0, &instance_size, |
| 12924 &in_object_properties); | 12925 &in_object_properties); |
| 12925 | 12926 |
| 12926 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); | 12927 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13137 script_source, Handle<Smi>::cast(class_start_position)->value(), | 13138 script_source, Handle<Smi>::cast(class_start_position)->value(), |
| 13138 Handle<Smi>::cast(class_end_position)->value()); | 13139 Handle<Smi>::cast(class_end_position)->value()); |
| 13139 } | 13140 } |
| 13140 | 13141 |
| 13141 // Check if we have source code for the {function}. | 13142 // Check if we have source code for the {function}. |
| 13142 if (!shared_info->HasSourceCode()) { | 13143 if (!shared_info->HasSourceCode()) { |
| 13143 return NativeCodeFunctionSourceString(shared_info); | 13144 return NativeCodeFunctionSourceString(shared_info); |
| 13144 } | 13145 } |
| 13145 | 13146 |
| 13146 IncrementalStringBuilder builder(isolate); | 13147 IncrementalStringBuilder builder(isolate); |
| 13147 if (!shared_info->is_arrow()) { | 13148 FunctionKind kind = shared_info->kind(); |
| 13148 if (shared_info->is_concise_method()) { | 13149 if (!IsArrowFunction(kind)) { |
| 13149 if (shared_info->is_generator()) { | 13150 if (IsConciseMethod(kind)) { |
| 13151 if (IsGeneratorFunction(kind)) { |
| 13150 builder.AppendCharacter('*'); | 13152 builder.AppendCharacter('*'); |
| 13151 } else if (shared_info->is_async()) { | 13153 } else if (IsAsyncFunction(kind)) { |
| 13152 builder.AppendCString("async "); | 13154 builder.AppendCString("async "); |
| 13153 } | 13155 } |
| 13154 } else { | 13156 } else { |
| 13155 if (shared_info->is_generator()) { | 13157 if (IsGeneratorFunction(kind)) { |
| 13156 builder.AppendCString("function* "); | 13158 builder.AppendCString("function* "); |
| 13157 } else if (shared_info->is_async()) { | 13159 } else if (IsAsyncFunction(kind)) { |
| 13158 builder.AppendCString("async function "); | 13160 builder.AppendCString("async function "); |
| 13159 } else { | 13161 } else { |
| 13160 builder.AppendCString("function "); | 13162 builder.AppendCString("function "); |
| 13161 } | 13163 } |
| 13162 } | 13164 } |
| 13163 if (shared_info->name_should_print_as_anonymous()) { | 13165 if (shared_info->name_should_print_as_anonymous()) { |
| 13164 builder.AppendCString("anonymous"); | 13166 builder.AppendCString("anonymous"); |
| 13165 } else if (!shared_info->is_anonymous_expression()) { | 13167 } else if (!shared_info->is_anonymous_expression()) { |
| 13166 builder.AppendString(handle(String::cast(shared_info->name()), isolate)); | 13168 builder.AppendString(handle(String::cast(shared_info->name()), isolate)); |
| 13167 } | 13169 } |
| (...skipping 6752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19920 | 19922 |
| 19921 Handle<JSFunction> function(JSFunction::cast(module->code()), isolate); | 19923 Handle<JSFunction> function(JSFunction::cast(module->code()), isolate); |
| 19922 DCHECK_EQ(MODULE_SCOPE, function->shared()->scope_info()->scope_type()); | 19924 DCHECK_EQ(MODULE_SCOPE, function->shared()->scope_info()->scope_type()); |
| 19923 Handle<Object> receiver = isolate->factory()->undefined_value(); | 19925 Handle<Object> receiver = isolate->factory()->undefined_value(); |
| 19924 Handle<Object> argv[] = {module}; | 19926 Handle<Object> argv[] = {module}; |
| 19925 return Execution::Call(isolate, function, receiver, arraysize(argv), argv); | 19927 return Execution::Call(isolate, function, receiver, arraysize(argv), argv); |
| 19926 } | 19928 } |
| 19927 | 19929 |
| 19928 } // namespace internal | 19930 } // namespace internal |
| 19929 } // namespace v8 | 19931 } // namespace v8 |
| OLD | NEW |