Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 case CompileTimeValue::ARRAY_LITERAL: | 453 case CompileTimeValue::ARRAY_LITERAL: |
| 454 return Runtime::CreateArrayLiteralBoilerplate( | 454 return Runtime::CreateArrayLiteralBoilerplate( |
| 455 isolate, literals, elements); | 455 isolate, literals, elements); |
| 456 default: | 456 default: |
| 457 UNREACHABLE(); | 457 UNREACHABLE(); |
| 458 return MaybeHandle<Object>(); | 458 return MaybeHandle<Object>(); |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 | 462 |
| 463 RUNTIME_FUNCTION(RuntimeHidden_CreateObjectLiteral) { | 463 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { |
| 464 HandleScope scope(isolate); | 464 HandleScope scope(isolate); |
| 465 ASSERT(args.length() == 4); | 465 ASSERT(args.length() == 4); |
| 466 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 466 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 467 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 467 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 468 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 468 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
| 469 CONVERT_SMI_ARG_CHECKED(flags, 3); | 469 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 470 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 470 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
| 471 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 471 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
| 472 | 472 |
| 473 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); | 473 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 | 567 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 |
| 568 ? JSObject::kNoHints | 568 ? JSObject::kNoHints |
| 569 : JSObject::kObjectIsShallowArray; | 569 : JSObject::kObjectIsShallowArray; |
| 570 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, | 570 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
| 571 hints); | 571 hints); |
| 572 usage_context.ExitScope(site, boilerplate); | 572 usage_context.ExitScope(site, boilerplate); |
| 573 return copy; | 573 return copy; |
| 574 } | 574 } |
| 575 | 575 |
| 576 | 576 |
| 577 RUNTIME_FUNCTION(RuntimeHidden_CreateArrayLiteral) { | 577 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { |
| 578 HandleScope scope(isolate); | 578 HandleScope scope(isolate); |
| 579 ASSERT(args.length() == 4); | 579 ASSERT(args.length() == 4); |
| 580 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 580 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 581 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 581 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 582 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 582 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 583 CONVERT_SMI_ARG_CHECKED(flags, 3); | 583 CONVERT_SMI_ARG_CHECKED(flags, 3); |
| 584 | 584 |
| 585 Handle<JSObject> result; | 585 Handle<JSObject> result; |
| 586 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 586 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 587 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 587 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 588 flags)); | 588 flags)); |
| 589 return *result; | 589 return *result; |
| 590 } | 590 } |
| 591 | 591 |
| 592 | 592 |
| 593 RUNTIME_FUNCTION(RuntimeHidden_CreateArrayLiteralStubBailout) { | 593 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) { |
| 594 HandleScope scope(isolate); | 594 HandleScope scope(isolate); |
| 595 ASSERT(args.length() == 3); | 595 ASSERT(args.length() == 3); |
| 596 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 596 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 597 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 597 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 598 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 598 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 599 | 599 |
| 600 Handle<JSObject> result; | 600 Handle<JSObject> result; |
| 601 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 601 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 602 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 602 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
| 603 ArrayLiteral::kShallowElements)); | 603 ArrayLiteral::kShallowElements)); |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2128 | 2128 |
| 2129 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { | 2129 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { |
| 2130 HandleScope scope(isolate); | 2130 HandleScope scope(isolate); |
| 2131 Handle<Object> args[1] = { name }; | 2131 Handle<Object> args[1] = { name }; |
| 2132 Handle<Object> error = isolate->factory()->NewTypeError( | 2132 Handle<Object> error = isolate->factory()->NewTypeError( |
| 2133 "var_redeclaration", HandleVector(args, 1)); | 2133 "var_redeclaration", HandleVector(args, 1)); |
| 2134 return isolate->Throw(*error); | 2134 return isolate->Throw(*error); |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 | 2137 |
| 2138 RUNTIME_FUNCTION(RuntimeHidden_DeclareGlobals) { | 2138 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { |
| 2139 HandleScope scope(isolate); | 2139 HandleScope scope(isolate); |
| 2140 ASSERT(args.length() == 3); | 2140 ASSERT(args.length() == 3); |
| 2141 Handle<GlobalObject> global = Handle<GlobalObject>( | 2141 Handle<GlobalObject> global = Handle<GlobalObject>( |
| 2142 isolate->context()->global_object()); | 2142 isolate->context()->global_object()); |
| 2143 | 2143 |
| 2144 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 2144 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 2145 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); | 2145 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); |
| 2146 CONVERT_SMI_ARG_CHECKED(flags, 2); | 2146 CONVERT_SMI_ARG_CHECKED(flags, 2); |
| 2147 | 2147 |
| 2148 // Traverse the name/value pairs and set the properties. | 2148 // Traverse the name/value pairs and set the properties. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2224 global, name, value, static_cast<PropertyAttributes>(attr), | 2224 global, name, value, static_cast<PropertyAttributes>(attr), |
| 2225 strict_mode)); | 2225 strict_mode)); |
| 2226 } | 2226 } |
| 2227 } | 2227 } |
| 2228 | 2228 |
| 2229 ASSERT(!isolate->has_pending_exception()); | 2229 ASSERT(!isolate->has_pending_exception()); |
| 2230 return isolate->heap()->undefined_value(); | 2230 return isolate->heap()->undefined_value(); |
| 2231 } | 2231 } |
| 2232 | 2232 |
| 2233 | 2233 |
| 2234 RUNTIME_FUNCTION(RuntimeHidden_DeclareContextSlot) { | 2234 RUNTIME_FUNCTION(Runtime_DeclareContextSlot) { |
| 2235 HandleScope scope(isolate); | 2235 HandleScope scope(isolate); |
| 2236 ASSERT(args.length() == 4); | 2236 ASSERT(args.length() == 4); |
| 2237 | 2237 |
| 2238 // Declarations are always made in a function or native context. In the | 2238 // Declarations are always made in a function or native context. In the |
| 2239 // case of eval code, the context passed is the context of the caller, | 2239 // case of eval code, the context passed is the context of the caller, |
| 2240 // which may be some nested context and not the declaration context. | 2240 // which may be some nested context and not the declaration context. |
| 2241 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); | 2241 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); |
| 2242 Handle<Context> context(context_arg->declaration_context()); | 2242 Handle<Context> context(context_arg->declaration_context()); |
| 2243 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 2243 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
| 2244 CONVERT_SMI_ARG_CHECKED(mode_arg, 2); | 2244 CONVERT_SMI_ARG_CHECKED(mode_arg, 2); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2384 Handle<Object> result; | 2384 Handle<Object> result; |
| 2385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2386 isolate, result, | 2386 isolate, result, |
| 2387 JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); | 2387 JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); |
| 2388 return *result; | 2388 return *result; |
| 2389 } | 2389 } |
| 2390 return isolate->heap()->undefined_value(); | 2390 return isolate->heap()->undefined_value(); |
| 2391 } | 2391 } |
| 2392 | 2392 |
| 2393 | 2393 |
| 2394 RUNTIME_FUNCTION(RuntimeHidden_InitializeConstGlobal) { | 2394 RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) { |
| 2395 SealHandleScope shs(isolate); | 2395 SealHandleScope shs(isolate); |
| 2396 // All constants are declared with an initial value. The name | 2396 // All constants are declared with an initial value. The name |
| 2397 // of the constant is the first argument and the initial value | 2397 // of the constant is the first argument and the initial value |
| 2398 // is the second. | 2398 // is the second. |
| 2399 RUNTIME_ASSERT(args.length() == 2); | 2399 RUNTIME_ASSERT(args.length() == 2); |
| 2400 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 2400 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 2401 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2401 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 2402 | 2402 |
| 2403 // Get the current global object from top. | 2403 // Get the current global object from top. |
| 2404 GlobalObject* global = isolate->context()->global_object(); | 2404 GlobalObject* global = isolate->context()->global_object(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2460 // Ignore re-initialization of constants that have already been | 2460 // Ignore re-initialization of constants that have already been |
| 2461 // assigned a constant value. | 2461 // assigned a constant value. |
| 2462 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); | 2462 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); |
| 2463 } | 2463 } |
| 2464 | 2464 |
| 2465 // Use the set value as the result of the operation. | 2465 // Use the set value as the result of the operation. |
| 2466 return *value; | 2466 return *value; |
| 2467 } | 2467 } |
| 2468 | 2468 |
| 2469 | 2469 |
| 2470 RUNTIME_FUNCTION(RuntimeHidden_InitializeConstContextSlot) { | 2470 RUNTIME_FUNCTION(Runtime_InitializeConstContextSlot) { |
| 2471 HandleScope scope(isolate); | 2471 HandleScope scope(isolate); |
| 2472 ASSERT(args.length() == 3); | 2472 ASSERT(args.length() == 3); |
| 2473 | 2473 |
| 2474 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 2474 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
| 2475 ASSERT(!value->IsTheHole()); | 2475 ASSERT(!value->IsTheHole()); |
| 2476 // Initializations are always done in a function or native context. | 2476 // Initializations are always done in a function or native context. |
| 2477 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); | 2477 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); |
| 2478 Handle<Context> context(context_arg->declaration_context()); | 2478 Handle<Context> context(context_arg->declaration_context()); |
| 2479 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 2479 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
| 2480 | 2480 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2571 CONVERT_SMI_ARG_CHECKED(properties, 1); | 2571 CONVERT_SMI_ARG_CHECKED(properties, 1); |
| 2572 // Conservative upper limit to prevent fuzz tests from going OOM. | 2572 // Conservative upper limit to prevent fuzz tests from going OOM. |
| 2573 RUNTIME_ASSERT(properties <= 100000); | 2573 RUNTIME_ASSERT(properties <= 100000); |
| 2574 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 2574 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
| 2575 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 2575 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
| 2576 } | 2576 } |
| 2577 return *object; | 2577 return *object; |
| 2578 } | 2578 } |
| 2579 | 2579 |
| 2580 | 2580 |
| 2581 RUNTIME_FUNCTION(RuntimeHidden_RegExpExec) { | 2581 RUNTIME_FUNCTION(Runtime_RegExpExec) { |
| 2582 HandleScope scope(isolate); | 2582 HandleScope scope(isolate); |
| 2583 ASSERT(args.length() == 4); | 2583 ASSERT(args.length() == 4); |
| 2584 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2584 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
| 2585 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 2585 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
| 2586 // Due to the way the JS calls are constructed this must be less than the | 2586 // Due to the way the JS calls are constructed this must be less than the |
| 2587 // length of a string, i.e. it is always a Smi. We check anyway for security. | 2587 // length of a string, i.e. it is always a Smi. We check anyway for security. |
| 2588 CONVERT_SMI_ARG_CHECKED(index, 2); | 2588 CONVERT_SMI_ARG_CHECKED(index, 2); |
| 2589 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 2589 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
| 2590 RUNTIME_ASSERT(index >= 0); | 2590 RUNTIME_ASSERT(index >= 0); |
| 2591 RUNTIME_ASSERT(index <= subject->length()); | 2591 RUNTIME_ASSERT(index <= subject->length()); |
| 2592 isolate->counters()->regexp_entry_runtime()->Increment(); | 2592 isolate->counters()->regexp_entry_runtime()->Increment(); |
| 2593 Handle<Object> result; | 2593 Handle<Object> result; |
| 2594 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2594 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2595 isolate, result, | 2595 isolate, result, |
| 2596 RegExpImpl::Exec(regexp, subject, index, last_match_info)); | 2596 RegExpImpl::Exec(regexp, subject, index, last_match_info)); |
| 2597 return *result; | 2597 return *result; |
| 2598 } | 2598 } |
| 2599 | 2599 |
| 2600 | 2600 |
| 2601 RUNTIME_FUNCTION(RuntimeHidden_RegExpConstructResult) { | 2601 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { |
| 2602 HandleScope handle_scope(isolate); | 2602 HandleScope handle_scope(isolate); |
| 2603 ASSERT(args.length() == 3); | 2603 ASSERT(args.length() == 3); |
| 2604 CONVERT_SMI_ARG_CHECKED(size, 0); | 2604 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 2605 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 2605 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
| 2606 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 2606 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
| 2607 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 2607 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
| 2608 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 2608 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
| 2609 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 2609 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
| 2610 Handle<JSObject> object = | 2610 Handle<JSObject> object = |
| 2611 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); | 2611 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2763 } | 2763 } |
| 2764 // Returns undefined for strict or native functions, or | 2764 // Returns undefined for strict or native functions, or |
| 2765 // the associated global receiver for "normal" functions. | 2765 // the associated global receiver for "normal" functions. |
| 2766 | 2766 |
| 2767 Context* native_context = | 2767 Context* native_context = |
| 2768 function->context()->global_object()->native_context(); | 2768 function->context()->global_object()->native_context(); |
| 2769 return native_context->global_object()->global_receiver(); | 2769 return native_context->global_object()->global_receiver(); |
| 2770 } | 2770 } |
| 2771 | 2771 |
| 2772 | 2772 |
| 2773 RUNTIME_FUNCTION(RuntimeHidden_MaterializeRegExpLiteral) { | 2773 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { |
| 2774 HandleScope scope(isolate); | 2774 HandleScope scope(isolate); |
| 2775 ASSERT(args.length() == 4); | 2775 ASSERT(args.length() == 4); |
| 2776 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 2776 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 2777 CONVERT_SMI_ARG_CHECKED(index, 1); | 2777 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 2778 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 2778 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
| 2779 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); | 2779 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
| 2780 | 2780 |
| 2781 // Get the RegExp function from the context in the literals array. | 2781 // Get the RegExp function from the context in the literals array. |
| 2782 // This is the RegExp function from the context in which the | 2782 // This is the RegExp function from the context in which the |
| 2783 // function was created. We do not use the RegExp function from the | 2783 // function was created. We do not use the RegExp function from the |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3012 if (isolate->logger()->is_logging_code_events() || | 3012 if (isolate->logger()->is_logging_code_events() || |
| 3013 isolate->cpu_profiler()->is_profiling()) { | 3013 isolate->cpu_profiler()->is_profiling()) { |
| 3014 isolate->logger()->LogExistingFunction( | 3014 isolate->logger()->LogExistingFunction( |
| 3015 source_shared, Handle<Code>(source_shared->code())); | 3015 source_shared, Handle<Code>(source_shared->code())); |
| 3016 } | 3016 } |
| 3017 | 3017 |
| 3018 return *target; | 3018 return *target; |
| 3019 } | 3019 } |
| 3020 | 3020 |
| 3021 | 3021 |
| 3022 RUNTIME_FUNCTION(RuntimeHidden_CreateJSGeneratorObject) { | 3022 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { |
| 3023 HandleScope scope(isolate); | 3023 HandleScope scope(isolate); |
| 3024 ASSERT(args.length() == 0); | 3024 ASSERT(args.length() == 0); |
| 3025 | 3025 |
| 3026 JavaScriptFrameIterator it(isolate); | 3026 JavaScriptFrameIterator it(isolate); |
| 3027 JavaScriptFrame* frame = it.frame(); | 3027 JavaScriptFrame* frame = it.frame(); |
| 3028 Handle<JSFunction> function(frame->function()); | 3028 Handle<JSFunction> function(frame->function()); |
| 3029 RUNTIME_ASSERT(function->shared()->is_generator()); | 3029 RUNTIME_ASSERT(function->shared()->is_generator()); |
| 3030 | 3030 |
| 3031 Handle<JSGeneratorObject> generator; | 3031 Handle<JSGeneratorObject> generator; |
| 3032 if (frame->IsConstructor()) { | 3032 if (frame->IsConstructor()) { |
| 3033 generator = handle(JSGeneratorObject::cast(frame->receiver())); | 3033 generator = handle(JSGeneratorObject::cast(frame->receiver())); |
| 3034 } else { | 3034 } else { |
| 3035 generator = isolate->factory()->NewJSGeneratorObject(function); | 3035 generator = isolate->factory()->NewJSGeneratorObject(function); |
| 3036 } | 3036 } |
| 3037 generator->set_function(*function); | 3037 generator->set_function(*function); |
| 3038 generator->set_context(Context::cast(frame->context())); | 3038 generator->set_context(Context::cast(frame->context())); |
| 3039 generator->set_receiver(frame->receiver()); | 3039 generator->set_receiver(frame->receiver()); |
| 3040 generator->set_continuation(0); | 3040 generator->set_continuation(0); |
| 3041 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); | 3041 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
| 3042 generator->set_stack_handler_index(-1); | 3042 generator->set_stack_handler_index(-1); |
| 3043 | 3043 |
| 3044 return *generator; | 3044 return *generator; |
| 3045 } | 3045 } |
| 3046 | 3046 |
| 3047 | 3047 |
| 3048 RUNTIME_FUNCTION(RuntimeHidden_SuspendJSGeneratorObject) { | 3048 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) { |
| 3049 HandleScope handle_scope(isolate); | 3049 HandleScope handle_scope(isolate); |
| 3050 ASSERT(args.length() == 1); | 3050 ASSERT(args.length() == 1); |
| 3051 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); | 3051 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); |
| 3052 | 3052 |
| 3053 JavaScriptFrameIterator stack_iterator(isolate); | 3053 JavaScriptFrameIterator stack_iterator(isolate); |
| 3054 JavaScriptFrame* frame = stack_iterator.frame(); | 3054 JavaScriptFrame* frame = stack_iterator.frame(); |
| 3055 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); | 3055 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); |
| 3056 ASSERT_EQ(frame->function(), generator_object->function()); | 3056 ASSERT_EQ(frame->function(), generator_object->function()); |
| 3057 | 3057 |
| 3058 // The caller should have saved the context and continuation already. | 3058 // The caller should have saved the context and continuation already. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 3088 } | 3088 } |
| 3089 | 3089 |
| 3090 | 3090 |
| 3091 // Note that this function is the slow path for resuming generators. It is only | 3091 // Note that this function is the slow path for resuming generators. It is only |
| 3092 // called if the suspended activation had operands on the stack, stack handlers | 3092 // called if the suspended activation had operands on the stack, stack handlers |
| 3093 // needing rewinding, or if the resume should throw an exception. The fast path | 3093 // needing rewinding, or if the resume should throw an exception. The fast path |
| 3094 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is | 3094 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is |
| 3095 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is | 3095 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is |
| 3096 // called in any case, as it needs to reconstruct the stack frame and make space | 3096 // called in any case, as it needs to reconstruct the stack frame and make space |
| 3097 // for arguments and operands. | 3097 // for arguments and operands. |
| 3098 RUNTIME_FUNCTION(RuntimeHidden_ResumeJSGeneratorObject) { | 3098 RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) { |
| 3099 SealHandleScope shs(isolate); | 3099 SealHandleScope shs(isolate); |
| 3100 ASSERT(args.length() == 3); | 3100 ASSERT(args.length() == 3); |
| 3101 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 3101 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
| 3102 CONVERT_ARG_CHECKED(Object, value, 1); | 3102 CONVERT_ARG_CHECKED(Object, value, 1); |
| 3103 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); | 3103 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); |
| 3104 JavaScriptFrameIterator stack_iterator(isolate); | 3104 JavaScriptFrameIterator stack_iterator(isolate); |
| 3105 JavaScriptFrame* frame = stack_iterator.frame(); | 3105 JavaScriptFrame* frame = stack_iterator.frame(); |
| 3106 | 3106 |
| 3107 ASSERT_EQ(frame->function(), generator_object->function()); | 3107 ASSERT_EQ(frame->function(), generator_object->function()); |
| 3108 ASSERT(frame->function()->is_compiled()); | 3108 ASSERT(frame->function()->is_compiled()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 3136 return value; | 3136 return value; |
| 3137 case JSGeneratorObject::THROW: | 3137 case JSGeneratorObject::THROW: |
| 3138 return isolate->Throw(value); | 3138 return isolate->Throw(value); |
| 3139 } | 3139 } |
| 3140 | 3140 |
| 3141 UNREACHABLE(); | 3141 UNREACHABLE(); |
| 3142 return isolate->ThrowIllegalOperation(); | 3142 return isolate->ThrowIllegalOperation(); |
| 3143 } | 3143 } |
| 3144 | 3144 |
| 3145 | 3145 |
| 3146 RUNTIME_FUNCTION(RuntimeHidden_ThrowGeneratorStateError) { | 3146 RUNTIME_FUNCTION(Runtime_ThrowGeneratorStateError) { |
| 3147 HandleScope scope(isolate); | 3147 HandleScope scope(isolate); |
| 3148 ASSERT(args.length() == 1); | 3148 ASSERT(args.length() == 1); |
| 3149 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 3149 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 3150 int continuation = generator->continuation(); | 3150 int continuation = generator->continuation(); |
| 3151 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? | 3151 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? |
| 3152 "generator_finished" : "generator_running"; | 3152 "generator_finished" : "generator_running"; |
| 3153 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); | 3153 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); |
| 3154 Handle<Object> error = isolate->factory()->NewError(message, argv); | 3154 Handle<Object> error = isolate->factory()->NewError(message, argv); |
| 3155 return isolate->Throw(*error); | 3155 return isolate->Throw(*error); |
| 3156 } | 3156 } |
| 3157 | 3157 |
| 3158 | 3158 |
| 3159 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { | 3159 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { |
| 3160 HandleScope scope(isolate); | 3160 HandleScope scope(isolate); |
| 3161 ASSERT(args.length() == 1); | 3161 ASSERT(args.length() == 1); |
| 3162 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 3162 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 3163 | 3163 |
| 3164 // %ObjectFreeze is a fast path and these cases are handled elsewhere. | 3164 // %ObjectFreeze is a fast path and these cases are handled elsewhere. |
| 3165 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && | 3165 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && |
| 3166 !object->map()->is_observed() && | 3166 !object->map()->is_observed() && |
| 3167 !object->IsJSProxy()); | 3167 !object->IsJSProxy()); |
| 3168 | 3168 |
| 3169 Handle<Object> result; | 3169 Handle<Object> result; |
| 3170 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); | 3170 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); |
| 3171 return *result; | 3171 return *result; |
| 3172 } | 3172 } |
| 3173 | 3173 |
| 3174 | 3174 |
| 3175 RUNTIME_FUNCTION(RuntimeHidden_StringCharCodeAt) { | 3175 RUNTIME_FUNCTION(Runtime_StringCharCodeAt) { |
| 3176 HandleScope handle_scope(isolate); | 3176 HandleScope handle_scope(isolate); |
| 3177 ASSERT(args.length() == 2); | 3177 ASSERT(args.length() == 2); |
| 3178 | 3178 |
| 3179 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 3179 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 3180 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 3180 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
| 3181 | 3181 |
| 3182 // Flatten the string. If someone wants to get a char at an index | 3182 // Flatten the string. If someone wants to get a char at an index |
| 3183 // in a cons string, it is likely that more indices will be | 3183 // in a cons string, it is likely that more indices will be |
| 3184 // accessed. | 3184 // accessed. |
| 3185 subject = String::Flatten(subject); | 3185 subject = String::Flatten(subject); |
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4441 for (int i = 0; i < end; i++) { | 4441 for (int i = 0; i < end; i++) { |
| 4442 if (flat1.Get(i) != flat2.Get(i)) { | 4442 if (flat1.Get(i) != flat2.Get(i)) { |
| 4443 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); | 4443 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); |
| 4444 } | 4444 } |
| 4445 } | 4445 } |
| 4446 | 4446 |
| 4447 return Smi::FromInt(str1_length - str2_length); | 4447 return Smi::FromInt(str1_length - str2_length); |
| 4448 } | 4448 } |
| 4449 | 4449 |
| 4450 | 4450 |
| 4451 RUNTIME_FUNCTION(RuntimeHidden_SubString) { | 4451 RUNTIME_FUNCTION(Runtime_SubString) { |
| 4452 HandleScope scope(isolate); | 4452 HandleScope scope(isolate); |
| 4453 ASSERT(args.length() == 3); | 4453 ASSERT(args.length() == 3); |
| 4454 | 4454 |
| 4455 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 4455 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
| 4456 int start, end; | 4456 int start, end; |
| 4457 // We have a fast integer-only case here to avoid a conversion to double in | 4457 // We have a fast integer-only case here to avoid a conversion to double in |
| 4458 // the common case where from and to are Smis. | 4458 // the common case where from and to are Smis. |
| 4459 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 4459 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
| 4460 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 4460 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
| 4461 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 4461 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
| (...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6826 } | 6826 } |
| 6827 | 6827 |
| 6828 | 6828 |
| 6829 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6829 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
| 6830 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6830 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
| 6831 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6831 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
| 6832 return char_length == 0; | 6832 return char_length == 0; |
| 6833 } | 6833 } |
| 6834 | 6834 |
| 6835 | 6835 |
| 6836 RUNTIME_FUNCTION(RuntimeHidden_NumberToString) { | 6836 RUNTIME_FUNCTION(Runtime_NumberToString) { |
| 6837 HandleScope scope(isolate); | 6837 HandleScope scope(isolate); |
| 6838 ASSERT(args.length() == 1); | 6838 ASSERT(args.length() == 1); |
| 6839 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6839 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
| 6840 | 6840 |
| 6841 return *isolate->factory()->NumberToString(number); | 6841 return *isolate->factory()->NumberToString(number); |
| 6842 } | 6842 } |
| 6843 | 6843 |
| 6844 | 6844 |
| 6845 RUNTIME_FUNCTION(RuntimeHidden_NumberToStringSkipCache) { | 6845 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) { |
| 6846 HandleScope scope(isolate); | 6846 HandleScope scope(isolate); |
| 6847 ASSERT(args.length() == 1); | 6847 ASSERT(args.length() == 1); |
| 6848 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6848 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
| 6849 | 6849 |
| 6850 return *isolate->factory()->NumberToString(number, false); | 6850 return *isolate->factory()->NumberToString(number, false); |
| 6851 } | 6851 } |
| 6852 | 6852 |
| 6853 | 6853 |
| 6854 RUNTIME_FUNCTION(Runtime_NumberToInteger) { | 6854 RUNTIME_FUNCTION(Runtime_NumberToInteger) { |
| 6855 HandleScope scope(isolate); | 6855 HandleScope scope(isolate); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 6886 HandleScope scope(isolate); | 6886 HandleScope scope(isolate); |
| 6887 ASSERT(args.length() == 1); | 6887 ASSERT(args.length() == 1); |
| 6888 | 6888 |
| 6889 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6889 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6890 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); | 6890 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); |
| 6891 } | 6891 } |
| 6892 | 6892 |
| 6893 | 6893 |
| 6894 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6894 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
| 6895 // a small integer. | 6895 // a small integer. |
| 6896 RUNTIME_FUNCTION(RuntimeHidden_NumberToSmi) { | 6896 RUNTIME_FUNCTION(Runtime_NumberToSmi) { |
| 6897 SealHandleScope shs(isolate); | 6897 SealHandleScope shs(isolate); |
| 6898 ASSERT(args.length() == 1); | 6898 ASSERT(args.length() == 1); |
| 6899 CONVERT_ARG_CHECKED(Object, obj, 0); | 6899 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 6900 if (obj->IsSmi()) { | 6900 if (obj->IsSmi()) { |
| 6901 return obj; | 6901 return obj; |
| 6902 } | 6902 } |
| 6903 if (obj->IsHeapNumber()) { | 6903 if (obj->IsHeapNumber()) { |
| 6904 double value = HeapNumber::cast(obj)->value(); | 6904 double value = HeapNumber::cast(obj)->value(); |
| 6905 int int_value = FastD2I(value); | 6905 int int_value = FastD2I(value); |
| 6906 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6906 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
| 6907 return Smi::FromInt(int_value); | 6907 return Smi::FromInt(int_value); |
| 6908 } | 6908 } |
| 6909 } | 6909 } |
| 6910 return isolate->heap()->nan_value(); | 6910 return isolate->heap()->nan_value(); |
| 6911 } | 6911 } |
| 6912 | 6912 |
| 6913 | 6913 |
| 6914 RUNTIME_FUNCTION(RuntimeHidden_AllocateHeapNumber) { | 6914 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { |
| 6915 HandleScope scope(isolate); | 6915 HandleScope scope(isolate); |
| 6916 ASSERT(args.length() == 0); | 6916 ASSERT(args.length() == 0); |
| 6917 return *isolate->factory()->NewHeapNumber(0); | 6917 return *isolate->factory()->NewHeapNumber(0); |
| 6918 } | 6918 } |
| 6919 | 6919 |
| 6920 | 6920 |
| 6921 RUNTIME_FUNCTION(Runtime_NumberAdd) { | 6921 RUNTIME_FUNCTION(Runtime_NumberAdd) { |
| 6922 HandleScope scope(isolate); | 6922 HandleScope scope(isolate); |
| 6923 ASSERT(args.length() == 2); | 6923 ASSERT(args.length() == 2); |
| 6924 | 6924 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6980 RUNTIME_FUNCTION(Runtime_NumberImul) { | 6980 RUNTIME_FUNCTION(Runtime_NumberImul) { |
| 6981 HandleScope scope(isolate); | 6981 HandleScope scope(isolate); |
| 6982 ASSERT(args.length() == 2); | 6982 ASSERT(args.length() == 2); |
| 6983 | 6983 |
| 6984 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6984 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6985 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6985 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6986 return *isolate->factory()->NewNumberFromInt(x * y); | 6986 return *isolate->factory()->NewNumberFromInt(x * y); |
| 6987 } | 6987 } |
| 6988 | 6988 |
| 6989 | 6989 |
| 6990 RUNTIME_FUNCTION(RuntimeHidden_StringAdd) { | 6990 RUNTIME_FUNCTION(Runtime_StringAdd) { |
| 6991 HandleScope scope(isolate); | 6991 HandleScope scope(isolate); |
| 6992 ASSERT(args.length() == 2); | 6992 ASSERT(args.length() == 2); |
| 6993 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 6993 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
| 6994 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 6994 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
| 6995 isolate->counters()->string_add_runtime()->Increment(); | 6995 isolate->counters()->string_add_runtime()->Increment(); |
| 6996 Handle<String> result; | 6996 Handle<String> result; |
| 6997 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6997 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6998 isolate, result, isolate->factory()->NewConsString(str1, str2)); | 6998 isolate, result, isolate->factory()->NewConsString(str1, str2)); |
| 6999 return *result; | 6999 return *result; |
| 7000 } | 7000 } |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7565 x_scaled /= 10; | 7565 x_scaled /= 10; |
| 7566 tie = GREATER; | 7566 tie = GREATER; |
| 7567 } | 7567 } |
| 7568 | 7568 |
| 7569 if (x_scaled < y_scaled) return Smi::FromInt(LESS); | 7569 if (x_scaled < y_scaled) return Smi::FromInt(LESS); |
| 7570 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); | 7570 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); |
| 7571 return Smi::FromInt(tie); | 7571 return Smi::FromInt(tie); |
| 7572 } | 7572 } |
| 7573 | 7573 |
| 7574 | 7574 |
| 7575 RUNTIME_FUNCTION(RuntimeHidden_StringCompare) { | 7575 RUNTIME_FUNCTION(Runtime_StringCompare) { |
| 7576 HandleScope handle_scope(isolate); | 7576 HandleScope handle_scope(isolate); |
| 7577 ASSERT(args.length() == 2); | 7577 ASSERT(args.length() == 2); |
| 7578 | 7578 |
| 7579 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7579 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
| 7580 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7580 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
| 7581 | 7581 |
| 7582 isolate->counters()->string_compare_runtime()->Increment(); | 7582 isolate->counters()->string_compare_runtime()->Increment(); |
| 7583 | 7583 |
| 7584 // A few fast case tests before we flatten. | 7584 // A few fast case tests before we flatten. |
| 7585 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); | 7585 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7726 ASSERT(args.length() == 1); | 7726 ASSERT(args.length() == 1); |
| 7727 isolate->counters()->math_floor()->Increment(); | 7727 isolate->counters()->math_floor()->Increment(); |
| 7728 | 7728 |
| 7729 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7729 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7730 return *isolate->factory()->NewNumber(std::floor(x)); | 7730 return *isolate->factory()->NewNumber(std::floor(x)); |
| 7731 } | 7731 } |
| 7732 | 7732 |
| 7733 | 7733 |
| 7734 // Slow version of Math.pow. We check for fast paths for special cases. | 7734 // Slow version of Math.pow. We check for fast paths for special cases. |
| 7735 // Used if VFP3 is not available. | 7735 // Used if VFP3 is not available. |
| 7736 RUNTIME_FUNCTION(RuntimeHidden_MathPowSlow) { | 7736 RUNTIME_FUNCTION(Runtime_MathPowSlow) { |
| 7737 HandleScope scope(isolate); | 7737 HandleScope scope(isolate); |
| 7738 ASSERT(args.length() == 2); | 7738 ASSERT(args.length() == 2); |
| 7739 isolate->counters()->math_pow()->Increment(); | 7739 isolate->counters()->math_pow()->Increment(); |
| 7740 | 7740 |
| 7741 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7741 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7742 | 7742 |
| 7743 // If the second argument is a smi, it is much faster to call the | 7743 // If the second argument is a smi, it is much faster to call the |
| 7744 // custom powi() function than the generic pow(). | 7744 // custom powi() function than the generic pow(). |
| 7745 if (args[1]->IsSmi()) { | 7745 if (args[1]->IsSmi()) { |
| 7746 int y = args.smi_at(1); | 7746 int y = args.smi_at(1); |
| 7747 return *isolate->factory()->NewNumber(power_double_int(x, y)); | 7747 return *isolate->factory()->NewNumber(power_double_int(x, y)); |
| 7748 } | 7748 } |
| 7749 | 7749 |
| 7750 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7750 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7751 double result = power_helper(x, y); | 7751 double result = power_helper(x, y); |
| 7752 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7752 if (std::isnan(result)) return isolate->heap()->nan_value(); |
| 7753 return *isolate->factory()->NewNumber(result); | 7753 return *isolate->factory()->NewNumber(result); |
| 7754 } | 7754 } |
| 7755 | 7755 |
| 7756 | 7756 |
| 7757 // Fast version of Math.pow if we know that y is not an integer and y is not | 7757 // Fast version of Math.pow if we know that y is not an integer and y is not |
| 7758 // -0.5 or 0.5. Used as slow case from full codegen. | 7758 // -0.5 or 0.5. Used as slow case from full codegen. |
| 7759 RUNTIME_FUNCTION(RuntimeHidden_MathPow) { | 7759 RUNTIME_FUNCTION(Runtime_MathPow) { |
| 7760 HandleScope scope(isolate); | 7760 HandleScope scope(isolate); |
| 7761 ASSERT(args.length() == 2); | 7761 ASSERT(args.length() == 2); |
| 7762 isolate->counters()->math_pow()->Increment(); | 7762 isolate->counters()->math_pow()->Increment(); |
| 7763 | 7763 |
| 7764 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7764 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7765 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7765 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7766 if (y == 0) { | 7766 if (y == 0) { |
| 7767 return Smi::FromInt(1); | 7767 return Smi::FromInt(1); |
| 7768 } else { | 7768 } else { |
| 7769 double result = power_double_double(x, y); | 7769 double result = power_double_double(x, y); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7877 is_value_nan = true; | 7877 is_value_nan = true; |
| 7878 } else { | 7878 } else { |
| 7879 value = isolate->factory()->NewNumber(DoubleToInteger(time)); | 7879 value = isolate->factory()->NewNumber(DoubleToInteger(time)); |
| 7880 } | 7880 } |
| 7881 } | 7881 } |
| 7882 date->SetValue(*value, is_value_nan); | 7882 date->SetValue(*value, is_value_nan); |
| 7883 return *value; | 7883 return *value; |
| 7884 } | 7884 } |
| 7885 | 7885 |
| 7886 | 7886 |
| 7887 RUNTIME_FUNCTION(RuntimeHidden_NewSloppyArguments) { | 7887 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { |
| 7888 HandleScope scope(isolate); | 7888 HandleScope scope(isolate); |
| 7889 ASSERT(args.length() == 3); | 7889 ASSERT(args.length() == 3); |
| 7890 | 7890 |
| 7891 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); | 7891 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
| 7892 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7892 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 7893 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 7893 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
| 7894 | 7894 |
| 7895 Handle<JSObject> result = | 7895 Handle<JSObject> result = |
| 7896 isolate->factory()->NewArgumentsObject(callee, argument_count); | 7896 isolate->factory()->NewArgumentsObject(callee, argument_count); |
| 7897 // Allocate the elements if needed. | 7897 // Allocate the elements if needed. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7971 result->set_elements(*elements); | 7971 result->set_elements(*elements); |
| 7972 for (int i = 0; i < argument_count; ++i) { | 7972 for (int i = 0; i < argument_count; ++i) { |
| 7973 elements->set(i, *(parameters - i - 1)); | 7973 elements->set(i, *(parameters - i - 1)); |
| 7974 } | 7974 } |
| 7975 } | 7975 } |
| 7976 } | 7976 } |
| 7977 return *result; | 7977 return *result; |
| 7978 } | 7978 } |
| 7979 | 7979 |
| 7980 | 7980 |
| 7981 RUNTIME_FUNCTION(RuntimeHidden_NewStrictArguments) { | 7981 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { |
| 7982 HandleScope scope(isolate); | 7982 HandleScope scope(isolate); |
| 7983 ASSERT(args.length() == 3); | 7983 ASSERT(args.length() == 3); |
| 7984 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 7984 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
| 7985 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7985 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 7986 CONVERT_SMI_ARG_CHECKED(length, 2); | 7986 CONVERT_SMI_ARG_CHECKED(length, 2); |
| 7987 | 7987 |
| 7988 Handle<JSObject> result = | 7988 Handle<JSObject> result = |
| 7989 isolate->factory()->NewArgumentsObject(callee, length); | 7989 isolate->factory()->NewArgumentsObject(callee, length); |
| 7990 | 7990 |
| 7991 if (length > 0) { | 7991 if (length > 0) { |
| 7992 Handle<FixedArray> array = | 7992 Handle<FixedArray> array = |
| 7993 isolate->factory()->NewUninitializedFixedArray(length); | 7993 isolate->factory()->NewUninitializedFixedArray(length); |
| 7994 DisallowHeapAllocation no_gc; | 7994 DisallowHeapAllocation no_gc; |
| 7995 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 7995 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 7996 for (int i = 0; i < length; i++) { | 7996 for (int i = 0; i < length; i++) { |
| 7997 array->set(i, *--parameters, mode); | 7997 array->set(i, *--parameters, mode); |
| 7998 } | 7998 } |
| 7999 result->set_elements(*array); | 7999 result->set_elements(*array); |
| 8000 } | 8000 } |
| 8001 return *result; | 8001 return *result; |
| 8002 } | 8002 } |
| 8003 | 8003 |
| 8004 | 8004 |
| 8005 RUNTIME_FUNCTION(RuntimeHidden_NewClosureFromStubFailure) { | 8005 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
| 8006 HandleScope scope(isolate); | 8006 HandleScope scope(isolate); |
| 8007 ASSERT(args.length() == 1); | 8007 ASSERT(args.length() == 1); |
| 8008 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 8008 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 8009 Handle<Context> context(isolate->context()); | 8009 Handle<Context> context(isolate->context()); |
| 8010 PretenureFlag pretenure_flag = NOT_TENURED; | 8010 PretenureFlag pretenure_flag = NOT_TENURED; |
| 8011 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8011 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 8012 shared, context, pretenure_flag); | 8012 shared, context, pretenure_flag); |
| 8013 } | 8013 } |
| 8014 | 8014 |
| 8015 | 8015 |
| 8016 RUNTIME_FUNCTION(RuntimeHidden_NewClosure) { | 8016 RUNTIME_FUNCTION(Runtime_NewClosure) { |
| 8017 HandleScope scope(isolate); | 8017 HandleScope scope(isolate); |
| 8018 ASSERT(args.length() == 3); | 8018 ASSERT(args.length() == 3); |
| 8019 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 8019 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 8020 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); | 8020 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); |
| 8021 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); | 8021 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); |
| 8022 | 8022 |
| 8023 // The caller ensures that we pretenure closures that are assigned | 8023 // The caller ensures that we pretenure closures that are assigned |
| 8024 // directly to properties. | 8024 // directly to properties. |
| 8025 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 8025 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
| 8026 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8026 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8261 result = isolate->factory()->NewJSObjectWithMemento(function, site); | 8261 result = isolate->factory()->NewJSObjectWithMemento(function, site); |
| 8262 } | 8262 } |
| 8263 | 8263 |
| 8264 isolate->counters()->constructed_objects()->Increment(); | 8264 isolate->counters()->constructed_objects()->Increment(); |
| 8265 isolate->counters()->constructed_objects_runtime()->Increment(); | 8265 isolate->counters()->constructed_objects_runtime()->Increment(); |
| 8266 | 8266 |
| 8267 return *result; | 8267 return *result; |
| 8268 } | 8268 } |
| 8269 | 8269 |
| 8270 | 8270 |
| 8271 RUNTIME_FUNCTION(RuntimeHidden_NewObject) { | 8271 RUNTIME_FUNCTION(Runtime_NewObject) { |
| 8272 HandleScope scope(isolate); | 8272 HandleScope scope(isolate); |
| 8273 ASSERT(args.length() == 1); | 8273 ASSERT(args.length() == 1); |
| 8274 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); | 8274 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); |
| 8275 return Runtime_NewObjectHelper(isolate, | 8275 return Runtime_NewObjectHelper(isolate, |
| 8276 constructor, | 8276 constructor, |
| 8277 Handle<AllocationSite>::null()); | 8277 Handle<AllocationSite>::null()); |
| 8278 } | 8278 } |
| 8279 | 8279 |
| 8280 | 8280 |
| 8281 RUNTIME_FUNCTION(RuntimeHidden_NewObjectWithAllocationSite) { | 8281 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) { |
| 8282 HandleScope scope(isolate); | 8282 HandleScope scope(isolate); |
| 8283 ASSERT(args.length() == 2); | 8283 ASSERT(args.length() == 2); |
| 8284 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); | 8284 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); |
| 8285 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); | 8285 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); |
| 8286 Handle<AllocationSite> site; | 8286 Handle<AllocationSite> site; |
| 8287 if (feedback->IsAllocationSite()) { | 8287 if (feedback->IsAllocationSite()) { |
| 8288 // The feedback can be an AllocationSite or undefined. | 8288 // The feedback can be an AllocationSite or undefined. |
| 8289 site = Handle<AllocationSite>::cast(feedback); | 8289 site = Handle<AllocationSite>::cast(feedback); |
| 8290 } | 8290 } |
| 8291 return Runtime_NewObjectHelper(isolate, constructor, site); | 8291 return Runtime_NewObjectHelper(isolate, constructor, site); |
| 8292 } | 8292 } |
| 8293 | 8293 |
| 8294 | 8294 |
| 8295 RUNTIME_FUNCTION(RuntimeHidden_FinalizeInstanceSize) { | 8295 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { |
| 8296 HandleScope scope(isolate); | 8296 HandleScope scope(isolate); |
| 8297 ASSERT(args.length() == 1); | 8297 ASSERT(args.length() == 1); |
| 8298 | 8298 |
| 8299 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8299 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8300 function->CompleteInobjectSlackTracking(); | 8300 function->CompleteInobjectSlackTracking(); |
| 8301 | 8301 |
| 8302 return isolate->heap()->undefined_value(); | 8302 return isolate->heap()->undefined_value(); |
| 8303 } | 8303 } |
| 8304 | 8304 |
| 8305 | 8305 |
| 8306 RUNTIME_FUNCTION(RuntimeHidden_CompileUnoptimized) { | 8306 RUNTIME_FUNCTION(Runtime_CompileUnoptimized) { |
| 8307 HandleScope scope(isolate); | 8307 HandleScope scope(isolate); |
| 8308 ASSERT(args.length() == 1); | 8308 ASSERT(args.length() == 1); |
| 8309 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8309 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8310 #ifdef DEBUG | 8310 #ifdef DEBUG |
| 8311 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 8311 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
| 8312 PrintF("[unoptimized: "); | 8312 PrintF("[unoptimized: "); |
| 8313 function->PrintName(); | 8313 function->PrintName(); |
| 8314 PrintF("]\n"); | 8314 PrintF("]\n"); |
| 8315 } | 8315 } |
| 8316 #endif | 8316 #endif |
| 8317 | 8317 |
| 8318 // Compile the target function. | 8318 // Compile the target function. |
| 8319 ASSERT(function->shared()->allows_lazy_compilation()); | 8319 ASSERT(function->shared()->allows_lazy_compilation()); |
| 8320 | 8320 |
| 8321 Handle<Code> code; | 8321 Handle<Code> code; |
| 8322 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, | 8322 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, |
| 8323 Compiler::GetUnoptimizedCode(function)); | 8323 Compiler::GetUnoptimizedCode(function)); |
| 8324 function->ReplaceCode(*code); | 8324 function->ReplaceCode(*code); |
| 8325 | 8325 |
| 8326 // All done. Return the compiled code. | 8326 // All done. Return the compiled code. |
| 8327 ASSERT(function->is_compiled()); | 8327 ASSERT(function->is_compiled()); |
| 8328 ASSERT(function->code()->kind() == Code::FUNCTION || | 8328 ASSERT(function->code()->kind() == Code::FUNCTION || |
| 8329 (FLAG_always_opt && | 8329 (FLAG_always_opt && |
| 8330 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); | 8330 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); |
| 8331 return *code; | 8331 return *code; |
| 8332 } | 8332 } |
| 8333 | 8333 |
| 8334 | 8334 |
| 8335 RUNTIME_FUNCTION(RuntimeHidden_CompileOptimized) { | 8335 RUNTIME_FUNCTION(Runtime_CompileOptimized) { |
| 8336 HandleScope scope(isolate); | 8336 HandleScope scope(isolate); |
| 8337 ASSERT(args.length() == 2); | 8337 ASSERT(args.length() == 2); |
| 8338 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8338 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8339 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); | 8339 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); |
| 8340 | 8340 |
| 8341 Handle<Code> unoptimized(function->shared()->code()); | 8341 Handle<Code> unoptimized(function->shared()->code()); |
| 8342 if (!function->shared()->is_compiled()) { | 8342 if (!function->shared()->is_compiled()) { |
| 8343 // If the function is not compiled, do not optimize. | 8343 // If the function is not compiled, do not optimize. |
| 8344 // This can happen if the debugger is activated and | 8344 // This can happen if the debugger is activated and |
| 8345 // the function is returned to the not compiled state. | 8345 // the function is returned to the not compiled state. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8393 | 8393 |
| 8394 void VisitFrames(JavaScriptFrameIterator* it) { | 8394 void VisitFrames(JavaScriptFrameIterator* it) { |
| 8395 for (; !it->done(); it->Advance()) { | 8395 for (; !it->done(); it->Advance()) { |
| 8396 JavaScriptFrame* frame = it->frame(); | 8396 JavaScriptFrame* frame = it->frame(); |
| 8397 if (code_->contains(frame->pc())) has_code_activations_ = true; | 8397 if (code_->contains(frame->pc())) has_code_activations_ = true; |
| 8398 } | 8398 } |
| 8399 } | 8399 } |
| 8400 }; | 8400 }; |
| 8401 | 8401 |
| 8402 | 8402 |
| 8403 RUNTIME_FUNCTION(RuntimeHidden_NotifyStubFailure) { | 8403 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) { |
| 8404 HandleScope scope(isolate); | 8404 HandleScope scope(isolate); |
| 8405 ASSERT(args.length() == 0); | 8405 ASSERT(args.length() == 0); |
| 8406 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8406 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8407 ASSERT(AllowHeapAllocation::IsAllowed()); | 8407 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 8408 delete deoptimizer; | 8408 delete deoptimizer; |
| 8409 return isolate->heap()->undefined_value(); | 8409 return isolate->heap()->undefined_value(); |
| 8410 } | 8410 } |
| 8411 | 8411 |
| 8412 | 8412 |
| 8413 RUNTIME_FUNCTION(RuntimeHidden_NotifyDeoptimized) { | 8413 RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { |
| 8414 HandleScope scope(isolate); | 8414 HandleScope scope(isolate); |
| 8415 ASSERT(args.length() == 1); | 8415 ASSERT(args.length() == 1); |
| 8416 CONVERT_SMI_ARG_CHECKED(type_arg, 0); | 8416 CONVERT_SMI_ARG_CHECKED(type_arg, 0); |
| 8417 Deoptimizer::BailoutType type = | 8417 Deoptimizer::BailoutType type = |
| 8418 static_cast<Deoptimizer::BailoutType>(type_arg); | 8418 static_cast<Deoptimizer::BailoutType>(type_arg); |
| 8419 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8419 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8420 ASSERT(AllowHeapAllocation::IsAllowed()); | 8420 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 8421 | 8421 |
| 8422 Handle<JSFunction> function = deoptimizer->function(); | 8422 Handle<JSFunction> function = deoptimizer->function(); |
| 8423 Handle<Code> optimized_code = deoptimizer->compiled_code(); | 8423 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8863 | 8863 |
| 8864 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { | 8864 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { |
| 8865 HandleScope scope(isolate); | 8865 HandleScope scope(isolate); |
| 8866 ASSERT(args.length() == 1); | 8866 ASSERT(args.length() == 1); |
| 8867 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8867 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 8868 RUNTIME_ASSERT(!object->IsJSFunction()); | 8868 RUNTIME_ASSERT(!object->IsJSFunction()); |
| 8869 return *Execution::GetConstructorDelegate(isolate, object); | 8869 return *Execution::GetConstructorDelegate(isolate, object); |
| 8870 } | 8870 } |
| 8871 | 8871 |
| 8872 | 8872 |
| 8873 RUNTIME_FUNCTION(RuntimeHidden_NewGlobalContext) { | 8873 RUNTIME_FUNCTION(Runtime_NewGlobalContext) { |
| 8874 HandleScope scope(isolate); | 8874 HandleScope scope(isolate); |
| 8875 ASSERT(args.length() == 2); | 8875 ASSERT(args.length() == 2); |
| 8876 | 8876 |
| 8877 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8877 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8878 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); | 8878 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
| 8879 Handle<Context> result = | 8879 Handle<Context> result = |
| 8880 isolate->factory()->NewGlobalContext(function, scope_info); | 8880 isolate->factory()->NewGlobalContext(function, scope_info); |
| 8881 | 8881 |
| 8882 ASSERT(function->context() == isolate->context()); | 8882 ASSERT(function->context() == isolate->context()); |
| 8883 ASSERT(function->context()->global_object() == result->global_object()); | 8883 ASSERT(function->context()->global_object() == result->global_object()); |
| 8884 result->global_object()->set_global_context(*result); | 8884 result->global_object()->set_global_context(*result); |
| 8885 return *result; | 8885 return *result; |
| 8886 } | 8886 } |
| 8887 | 8887 |
| 8888 | 8888 |
| 8889 RUNTIME_FUNCTION(RuntimeHidden_NewFunctionContext) { | 8889 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { |
| 8890 HandleScope scope(isolate); | 8890 HandleScope scope(isolate); |
| 8891 ASSERT(args.length() == 1); | 8891 ASSERT(args.length() == 1); |
| 8892 | 8892 |
| 8893 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8893 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8894 int length = function->shared()->scope_info()->ContextLength(); | 8894 int length = function->shared()->scope_info()->ContextLength(); |
| 8895 return *isolate->factory()->NewFunctionContext(length, function); | 8895 return *isolate->factory()->NewFunctionContext(length, function); |
| 8896 } | 8896 } |
| 8897 | 8897 |
| 8898 | 8898 |
| 8899 RUNTIME_FUNCTION(RuntimeHidden_PushWithContext) { | 8899 RUNTIME_FUNCTION(Runtime_PushWithContext) { |
| 8900 HandleScope scope(isolate); | 8900 HandleScope scope(isolate); |
| 8901 ASSERT(args.length() == 2); | 8901 ASSERT(args.length() == 2); |
| 8902 Handle<JSReceiver> extension_object; | 8902 Handle<JSReceiver> extension_object; |
| 8903 if (args[0]->IsJSReceiver()) { | 8903 if (args[0]->IsJSReceiver()) { |
| 8904 extension_object = args.at<JSReceiver>(0); | 8904 extension_object = args.at<JSReceiver>(0); |
| 8905 } else { | 8905 } else { |
| 8906 // Try to convert the object to a proper JavaScript object. | 8906 // Try to convert the object to a proper JavaScript object. |
| 8907 MaybeHandle<JSReceiver> maybe_object = | 8907 MaybeHandle<JSReceiver> maybe_object = |
| 8908 Object::ToObject(isolate, args.at<Object>(0)); | 8908 Object::ToObject(isolate, args.at<Object>(0)); |
| 8909 if (!maybe_object.ToHandle(&extension_object)) { | 8909 if (!maybe_object.ToHandle(&extension_object)) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 8926 } | 8926 } |
| 8927 | 8927 |
| 8928 Handle<Context> current(isolate->context()); | 8928 Handle<Context> current(isolate->context()); |
| 8929 Handle<Context> context = isolate->factory()->NewWithContext( | 8929 Handle<Context> context = isolate->factory()->NewWithContext( |
| 8930 function, current, extension_object); | 8930 function, current, extension_object); |
| 8931 isolate->set_context(*context); | 8931 isolate->set_context(*context); |
| 8932 return *context; | 8932 return *context; |
| 8933 } | 8933 } |
| 8934 | 8934 |
| 8935 | 8935 |
| 8936 RUNTIME_FUNCTION(RuntimeHidden_PushCatchContext) { | 8936 RUNTIME_FUNCTION(Runtime_PushCatchContext) { |
| 8937 HandleScope scope(isolate); | 8937 HandleScope scope(isolate); |
| 8938 ASSERT(args.length() == 3); | 8938 ASSERT(args.length() == 3); |
| 8939 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 8939 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 8940 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); | 8940 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
| 8941 Handle<JSFunction> function; | 8941 Handle<JSFunction> function; |
| 8942 if (args[2]->IsSmi()) { | 8942 if (args[2]->IsSmi()) { |
| 8943 // A smi sentinel indicates a context nested inside global code rather | 8943 // A smi sentinel indicates a context nested inside global code rather |
| 8944 // than some function. There is a canonical empty function that can be | 8944 // than some function. There is a canonical empty function that can be |
| 8945 // gotten from the native context. | 8945 // gotten from the native context. |
| 8946 function = handle(isolate->context()->native_context()->closure()); | 8946 function = handle(isolate->context()->native_context()->closure()); |
| 8947 } else { | 8947 } else { |
| 8948 function = args.at<JSFunction>(2); | 8948 function = args.at<JSFunction>(2); |
| 8949 } | 8949 } |
| 8950 Handle<Context> current(isolate->context()); | 8950 Handle<Context> current(isolate->context()); |
| 8951 Handle<Context> context = isolate->factory()->NewCatchContext( | 8951 Handle<Context> context = isolate->factory()->NewCatchContext( |
| 8952 function, current, name, thrown_object); | 8952 function, current, name, thrown_object); |
| 8953 isolate->set_context(*context); | 8953 isolate->set_context(*context); |
| 8954 return *context; | 8954 return *context; |
| 8955 } | 8955 } |
| 8956 | 8956 |
| 8957 | 8957 |
| 8958 RUNTIME_FUNCTION(RuntimeHidden_PushBlockContext) { | 8958 RUNTIME_FUNCTION(Runtime_PushBlockContext) { |
| 8959 HandleScope scope(isolate); | 8959 HandleScope scope(isolate); |
| 8960 ASSERT(args.length() == 2); | 8960 ASSERT(args.length() == 2); |
| 8961 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); | 8961 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
| 8962 Handle<JSFunction> function; | 8962 Handle<JSFunction> function; |
| 8963 if (args[1]->IsSmi()) { | 8963 if (args[1]->IsSmi()) { |
| 8964 // A smi sentinel indicates a context nested inside global code rather | 8964 // A smi sentinel indicates a context nested inside global code rather |
| 8965 // than some function. There is a canonical empty function that can be | 8965 // than some function. There is a canonical empty function that can be |
| 8966 // gotten from the native context. | 8966 // gotten from the native context. |
| 8967 function = handle(isolate->context()->native_context()->closure()); | 8967 function = handle(isolate->context()->native_context()->closure()); |
| 8968 } else { | 8968 } else { |
| 8969 function = args.at<JSFunction>(1); | 8969 function = args.at<JSFunction>(1); |
| 8970 } | 8970 } |
| 8971 Handle<Context> current(isolate->context()); | 8971 Handle<Context> current(isolate->context()); |
| 8972 Handle<Context> context = isolate->factory()->NewBlockContext( | 8972 Handle<Context> context = isolate->factory()->NewBlockContext( |
| 8973 function, current, scope_info); | 8973 function, current, scope_info); |
| 8974 isolate->set_context(*context); | 8974 isolate->set_context(*context); |
| 8975 return *context; | 8975 return *context; |
| 8976 } | 8976 } |
| 8977 | 8977 |
| 8978 | 8978 |
| 8979 RUNTIME_FUNCTION(Runtime_IsJSModule) { | 8979 RUNTIME_FUNCTION(Runtime_IsJSModule) { |
| 8980 SealHandleScope shs(isolate); | 8980 SealHandleScope shs(isolate); |
| 8981 ASSERT(args.length() == 1); | 8981 ASSERT(args.length() == 1); |
| 8982 CONVERT_ARG_CHECKED(Object, obj, 0); | 8982 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 8983 return isolate->heap()->ToBoolean(obj->IsJSModule()); | 8983 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
| 8984 } | 8984 } |
| 8985 | 8985 |
| 8986 | 8986 |
| 8987 RUNTIME_FUNCTION(RuntimeHidden_PushModuleContext) { | 8987 RUNTIME_FUNCTION(Runtime_PushModuleContext) { |
| 8988 SealHandleScope shs(isolate); | 8988 SealHandleScope shs(isolate); |
| 8989 ASSERT(args.length() == 2); | 8989 ASSERT(args.length() == 2); |
| 8990 CONVERT_SMI_ARG_CHECKED(index, 0); | 8990 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 8991 | 8991 |
| 8992 if (!args[1]->IsScopeInfo()) { | 8992 if (!args[1]->IsScopeInfo()) { |
| 8993 // Module already initialized. Find hosting context and retrieve context. | 8993 // Module already initialized. Find hosting context and retrieve context. |
| 8994 Context* host = Context::cast(isolate->context())->global_context(); | 8994 Context* host = Context::cast(isolate->context())->global_context(); |
| 8995 Context* context = Context::cast(host->get(index)); | 8995 Context* context = Context::cast(host->get(index)); |
| 8996 ASSERT(context->previous() == isolate->context()); | 8996 ASSERT(context->previous() == isolate->context()); |
| 8997 isolate->set_context(context); | 8997 isolate->set_context(context); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 9012 context->set_global_object(previous->global_object()); | 9012 context->set_global_object(previous->global_object()); |
| 9013 isolate->set_context(*context); | 9013 isolate->set_context(*context); |
| 9014 | 9014 |
| 9015 // Find hosting scope and initialize internal variable holding module there. | 9015 // Find hosting scope and initialize internal variable holding module there. |
| 9016 previous->global_context()->set(index, *context); | 9016 previous->global_context()->set(index, *context); |
| 9017 | 9017 |
| 9018 return *context; | 9018 return *context; |
| 9019 } | 9019 } |
| 9020 | 9020 |
| 9021 | 9021 |
| 9022 RUNTIME_FUNCTION(RuntimeHidden_DeclareModules) { | 9022 RUNTIME_FUNCTION(Runtime_DeclareModules) { |
| 9023 HandleScope scope(isolate); | 9023 HandleScope scope(isolate); |
| 9024 ASSERT(args.length() == 1); | 9024 ASSERT(args.length() == 1); |
| 9025 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); | 9025 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); |
| 9026 Context* host_context = isolate->context(); | 9026 Context* host_context = isolate->context(); |
| 9027 | 9027 |
| 9028 for (int i = 0; i < descriptions->length(); ++i) { | 9028 for (int i = 0; i < descriptions->length(); ++i) { |
| 9029 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); | 9029 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); |
| 9030 int host_index = description->host_index(); | 9030 int host_index = description->host_index(); |
| 9031 Handle<Context> context(Context::cast(host_context->get(host_index))); | 9031 Handle<Context> context(Context::cast(host_context->get(host_index))); |
| 9032 Handle<JSModule> module(context->module()); | 9032 Handle<JSModule> module(context->module()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9066 } | 9066 } |
| 9067 | 9067 |
| 9068 JSObject::PreventExtensions(module).Assert(); | 9068 JSObject::PreventExtensions(module).Assert(); |
| 9069 } | 9069 } |
| 9070 | 9070 |
| 9071 ASSERT(!isolate->has_pending_exception()); | 9071 ASSERT(!isolate->has_pending_exception()); |
| 9072 return isolate->heap()->undefined_value(); | 9072 return isolate->heap()->undefined_value(); |
| 9073 } | 9073 } |
| 9074 | 9074 |
| 9075 | 9075 |
| 9076 RUNTIME_FUNCTION(RuntimeHidden_DeleteContextSlot) { | 9076 RUNTIME_FUNCTION(Runtime_DeleteContextSlot) { |
| 9077 HandleScope scope(isolate); | 9077 HandleScope scope(isolate); |
| 9078 ASSERT(args.length() == 2); | 9078 ASSERT(args.length() == 2); |
| 9079 | 9079 |
| 9080 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 9080 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 9081 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 9081 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
| 9082 | 9082 |
| 9083 int index; | 9083 int index; |
| 9084 PropertyAttributes attributes; | 9084 PropertyAttributes attributes; |
| 9085 ContextLookupFlags flags = FOLLOW_CHAINS; | 9085 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 9086 BindingFlags binding_flags; | 9086 BindingFlags binding_flags; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9277 HandleVector(&name, 1)); | 9277 HandleVector(&name, 1)); |
| 9278 return MakePair(isolate->Throw(*reference_error), NULL); | 9278 return MakePair(isolate->Throw(*reference_error), NULL); |
| 9279 } else { | 9279 } else { |
| 9280 // The property doesn't exist - return undefined. | 9280 // The property doesn't exist - return undefined. |
| 9281 return MakePair(isolate->heap()->undefined_value(), | 9281 return MakePair(isolate->heap()->undefined_value(), |
| 9282 isolate->heap()->undefined_value()); | 9282 isolate->heap()->undefined_value()); |
| 9283 } | 9283 } |
| 9284 } | 9284 } |
| 9285 | 9285 |
| 9286 | 9286 |
| 9287 RUNTIME_FUNCTION_RETURN_PAIR(RuntimeHidden_LoadContextSlot) { | 9287 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadContextSlot) { |
| 9288 return LoadContextSlotHelper(args, isolate, true); | 9288 return LoadContextSlotHelper(args, isolate, true); |
| 9289 } | 9289 } |
| 9290 | 9290 |
| 9291 | 9291 |
| 9292 RUNTIME_FUNCTION_RETURN_PAIR(RuntimeHidden_LoadContextSlotNoReferenceError) { | 9292 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadContextSlotNoReferenceError) { |
| 9293 return LoadContextSlotHelper(args, isolate, false); | 9293 return LoadContextSlotHelper(args, isolate, false); |
| 9294 } | 9294 } |
| 9295 | 9295 |
| 9296 | 9296 |
| 9297 RUNTIME_FUNCTION(RuntimeHidden_StoreContextSlot) { | 9297 RUNTIME_FUNCTION(Runtime_StoreContextSlot) { |
| 9298 HandleScope scope(isolate); | 9298 HandleScope scope(isolate); |
| 9299 ASSERT(args.length() == 4); | 9299 ASSERT(args.length() == 4); |
| 9300 | 9300 |
| 9301 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 9301 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
| 9302 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); | 9302 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); |
| 9303 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 9303 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
| 9304 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); | 9304 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); |
| 9305 | 9305 |
| 9306 int index; | 9306 int index; |
| 9307 PropertyAttributes attributes; | 9307 PropertyAttributes attributes; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9372 // Setting read only property in strict mode. | 9372 // Setting read only property in strict mode. |
| 9373 Handle<Object> error = | 9373 Handle<Object> error = |
| 9374 isolate->factory()->NewTypeError( | 9374 isolate->factory()->NewTypeError( |
| 9375 "strict_cannot_assign", HandleVector(&name, 1)); | 9375 "strict_cannot_assign", HandleVector(&name, 1)); |
| 9376 return isolate->Throw(*error); | 9376 return isolate->Throw(*error); |
| 9377 } | 9377 } |
| 9378 return *value; | 9378 return *value; |
| 9379 } | 9379 } |
| 9380 | 9380 |
| 9381 | 9381 |
| 9382 RUNTIME_FUNCTION(RuntimeHidden_Throw) { | 9382 RUNTIME_FUNCTION(Runtime_Throw) { |
| 9383 HandleScope scope(isolate); | 9383 HandleScope scope(isolate); |
| 9384 ASSERT(args.length() == 1); | 9384 ASSERT(args.length() == 1); |
| 9385 | 9385 |
| 9386 return isolate->Throw(args[0]); | 9386 return isolate->Throw(args[0]); |
| 9387 } | 9387 } |
| 9388 | 9388 |
| 9389 | 9389 |
| 9390 RUNTIME_FUNCTION(RuntimeHidden_ReThrow) { | 9390 RUNTIME_FUNCTION(Runtime_ReThrow) { |
| 9391 HandleScope scope(isolate); | 9391 HandleScope scope(isolate); |
| 9392 ASSERT(args.length() == 1); | 9392 ASSERT(args.length() == 1); |
| 9393 | 9393 |
| 9394 return isolate->ReThrow(args[0]); | 9394 return isolate->ReThrow(args[0]); |
| 9395 } | 9395 } |
| 9396 | 9396 |
| 9397 | 9397 |
| 9398 RUNTIME_FUNCTION(RuntimeHidden_PromoteScheduledException) { | 9398 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { |
| 9399 SealHandleScope shs(isolate); | 9399 SealHandleScope shs(isolate); |
| 9400 ASSERT(args.length() == 0); | 9400 ASSERT(args.length() == 0); |
| 9401 return isolate->PromoteScheduledException(); | 9401 return isolate->PromoteScheduledException(); |
| 9402 } | 9402 } |
| 9403 | 9403 |
| 9404 | 9404 |
| 9405 RUNTIME_FUNCTION(RuntimeHidden_ThrowReferenceError) { | 9405 RUNTIME_FUNCTION(Runtime_ThrowReferenceError) { |
| 9406 HandleScope scope(isolate); | 9406 HandleScope scope(isolate); |
| 9407 ASSERT(args.length() == 1); | 9407 ASSERT(args.length() == 1); |
| 9408 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 9408 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
| 9409 Handle<Object> reference_error = | 9409 Handle<Object> reference_error = |
| 9410 isolate->factory()->NewReferenceError("not_defined", | 9410 isolate->factory()->NewReferenceError("not_defined", |
| 9411 HandleVector(&name, 1)); | 9411 HandleVector(&name, 1)); |
| 9412 return isolate->Throw(*reference_error); | 9412 return isolate->Throw(*reference_error); |
| 9413 } | 9413 } |
| 9414 | 9414 |
| 9415 | 9415 |
| 9416 RUNTIME_FUNCTION(RuntimeHidden_ThrowNotDateError) { | 9416 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { |
| 9417 HandleScope scope(isolate); | 9417 HandleScope scope(isolate); |
| 9418 ASSERT(args.length() == 0); | 9418 ASSERT(args.length() == 0); |
| 9419 return isolate->Throw(*isolate->factory()->NewTypeError( | 9419 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 9420 "not_date_object", HandleVector<Object>(NULL, 0))); | 9420 "not_date_object", HandleVector<Object>(NULL, 0))); |
| 9421 } | 9421 } |
| 9422 | 9422 |
| 9423 | 9423 |
| 9424 RUNTIME_FUNCTION(RuntimeHidden_StackGuard) { | 9424 RUNTIME_FUNCTION(Runtime_StackGuard) { |
| 9425 SealHandleScope shs(isolate); | 9425 SealHandleScope shs(isolate); |
| 9426 ASSERT(args.length() == 0); | 9426 ASSERT(args.length() == 0); |
| 9427 | 9427 |
| 9428 // First check if this is a real stack overflow. | 9428 // First check if this is a real stack overflow. |
| 9429 StackLimitCheck check(isolate); | 9429 StackLimitCheck check(isolate); |
| 9430 if (check.JsHasOverflowed()) { | 9430 if (check.JsHasOverflowed()) { |
| 9431 return isolate->StackOverflow(); | 9431 return isolate->StackOverflow(); |
| 9432 } | 9432 } |
| 9433 | 9433 |
| 9434 return isolate->stack_guard()->HandleInterrupts(); | 9434 return isolate->stack_guard()->HandleInterrupts(); |
| 9435 } | 9435 } |
| 9436 | 9436 |
| 9437 | 9437 |
| 9438 RUNTIME_FUNCTION(RuntimeHidden_TryInstallOptimizedCode) { | 9438 RUNTIME_FUNCTION(Runtime_TryInstallOptimizedCode) { |
| 9439 HandleScope scope(isolate); | 9439 HandleScope scope(isolate); |
| 9440 ASSERT(args.length() == 1); | 9440 ASSERT(args.length() == 1); |
| 9441 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 9441 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 9442 | 9442 |
| 9443 // First check if this is a real stack overflow. | 9443 // First check if this is a real stack overflow. |
| 9444 StackLimitCheck check(isolate); | 9444 StackLimitCheck check(isolate); |
| 9445 if (check.JsHasOverflowed()) { | 9445 if (check.JsHasOverflowed()) { |
| 9446 SealHandleScope shs(isolate); | 9446 SealHandleScope shs(isolate); |
| 9447 return isolate->StackOverflow(); | 9447 return isolate->StackOverflow(); |
| 9448 } | 9448 } |
| 9449 | 9449 |
| 9450 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 9450 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 9451 return (function->IsOptimized()) ? function->code() | 9451 return (function->IsOptimized()) ? function->code() |
| 9452 : function->shared()->code(); | 9452 : function->shared()->code(); |
| 9453 } | 9453 } |
| 9454 | 9454 |
| 9455 | 9455 |
| 9456 RUNTIME_FUNCTION(RuntimeHidden_Interrupt) { | 9456 RUNTIME_FUNCTION(Runtime_Interrupt) { |
| 9457 SealHandleScope shs(isolate); | 9457 SealHandleScope shs(isolate); |
| 9458 ASSERT(args.length() == 0); | 9458 ASSERT(args.length() == 0); |
| 9459 return isolate->stack_guard()->HandleInterrupts(); | 9459 return isolate->stack_guard()->HandleInterrupts(); |
| 9460 } | 9460 } |
| 9461 | 9461 |
| 9462 | 9462 |
| 9463 static int StackSize(Isolate* isolate) { | 9463 static int StackSize(Isolate* isolate) { |
| 9464 int n = 0; | 9464 int n = 0; |
| 9465 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; | 9465 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
| 9466 return n; | 9466 return n; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9816 Handle<JSFunction> compiled; | 9816 Handle<JSFunction> compiled; |
| 9817 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9817 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 9818 isolate, compiled, | 9818 isolate, compiled, |
| 9819 Compiler::GetFunctionFromEval( | 9819 Compiler::GetFunctionFromEval( |
| 9820 source, context, strict_mode, restriction, scope_position), | 9820 source, context, strict_mode, restriction, scope_position), |
| 9821 MakePair(isolate->heap()->exception(), NULL)); | 9821 MakePair(isolate->heap()->exception(), NULL)); |
| 9822 return MakePair(*compiled, *receiver); | 9822 return MakePair(*compiled, *receiver); |
| 9823 } | 9823 } |
| 9824 | 9824 |
| 9825 | 9825 |
| 9826 RUNTIME_FUNCTION_RETURN_PAIR(RuntimeHidden_ResolvePossiblyDirectEval) { | 9826 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval) { |
| 9827 HandleScope scope(isolate); | 9827 HandleScope scope(isolate); |
| 9828 ASSERT(args.length() == 5); | 9828 ASSERT(args.length() == 5); |
| 9829 | 9829 |
| 9830 Handle<Object> callee = args.at<Object>(0); | 9830 Handle<Object> callee = args.at<Object>(0); |
| 9831 | 9831 |
| 9832 // If "eval" didn't refer to the original GlobalEval, it's not a | 9832 // If "eval" didn't refer to the original GlobalEval, it's not a |
| 9833 // direct call to eval. | 9833 // direct call to eval. |
| 9834 // (And even if it is, but the first argument isn't a string, just let | 9834 // (And even if it is, but the first argument isn't a string, just let |
| 9835 // execution default to an indirect call to eval, which will also return | 9835 // execution default to an indirect call to eval, which will also return |
| 9836 // the first argument without doing anything). | 9836 // the first argument without doing anything). |
| 9837 if (*callee != isolate->native_context()->global_eval_fun() || | 9837 if (*callee != isolate->native_context()->global_eval_fun() || |
| 9838 !args[1]->IsString()) { | 9838 !args[1]->IsString()) { |
| 9839 return MakePair(*callee, isolate->heap()->undefined_value()); | 9839 return MakePair(*callee, isolate->heap()->undefined_value()); |
| 9840 } | 9840 } |
| 9841 | 9841 |
| 9842 ASSERT(args[3]->IsSmi()); | 9842 ASSERT(args[3]->IsSmi()); |
| 9843 ASSERT(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT); | 9843 ASSERT(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT); |
| 9844 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); | 9844 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); |
| 9845 ASSERT(args[4]->IsSmi()); | 9845 ASSERT(args[4]->IsSmi()); |
| 9846 return CompileGlobalEval(isolate, | 9846 return CompileGlobalEval(isolate, |
| 9847 args.at<String>(1), | 9847 args.at<String>(1), |
| 9848 args.at<Object>(2), | 9848 args.at<Object>(2), |
| 9849 strict_mode, | 9849 strict_mode, |
| 9850 args.smi_at(4)); | 9850 args.smi_at(4)); |
| 9851 } | 9851 } |
| 9852 | 9852 |
| 9853 | 9853 |
| 9854 RUNTIME_FUNCTION(RuntimeHidden_AllocateInNewSpace) { | 9854 RUNTIME_FUNCTION(Runtime_AllocateInNewSpace) { |
| 9855 HandleScope scope(isolate); | 9855 HandleScope scope(isolate); |
| 9856 ASSERT(args.length() == 1); | 9856 ASSERT(args.length() == 1); |
| 9857 CONVERT_SMI_ARG_CHECKED(size, 0); | 9857 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 9858 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9858 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
| 9859 RUNTIME_ASSERT(size > 0); | 9859 RUNTIME_ASSERT(size > 0); |
| 9860 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9860 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
| 9861 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); | 9861 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); |
| 9862 } | 9862 } |
| 9863 | 9863 |
| 9864 | 9864 |
| 9865 RUNTIME_FUNCTION(RuntimeHidden_AllocateInTargetSpace) { | 9865 RUNTIME_FUNCTION(Runtime_AllocateInTargetSpace) { |
| 9866 HandleScope scope(isolate); | 9866 HandleScope scope(isolate); |
| 9867 ASSERT(args.length() == 2); | 9867 ASSERT(args.length() == 2); |
| 9868 CONVERT_SMI_ARG_CHECKED(size, 0); | 9868 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 9869 CONVERT_SMI_ARG_CHECKED(flags, 1); | 9869 CONVERT_SMI_ARG_CHECKED(flags, 1); |
| 9870 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9870 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
| 9871 RUNTIME_ASSERT(size > 0); | 9871 RUNTIME_ASSERT(size > 0); |
| 9872 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9872 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
| 9873 bool double_align = AllocateDoubleAlignFlag::decode(flags); | 9873 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
| 9874 AllocationSpace space = AllocateTargetSpace::decode(flags); | 9874 AllocationSpace space = AllocateTargetSpace::decode(flags); |
| 9875 return *isolate->factory()->NewFillerObject(size, double_align, space); | 9875 return *isolate->factory()->NewFillerObject(size, double_align, space); |
| (...skipping 4674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14550 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); | 14550 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); |
| 14551 // This call must not cause lazy deopts, because it's called from deferred | 14551 // This call must not cause lazy deopts, because it's called from deferred |
| 14552 // code where we can't handle lazy deopts for lack of a suitable bailout | 14552 // code where we can't handle lazy deopts for lack of a suitable bailout |
| 14553 // ID. So we just try migration and signal failure if necessary, | 14553 // ID. So we just try migration and signal failure if necessary, |
| 14554 // which will also trigger a deopt. | 14554 // which will also trigger a deopt. |
| 14555 if (!JSObject::TryMigrateInstance(js_object)) return Smi::FromInt(0); | 14555 if (!JSObject::TryMigrateInstance(js_object)) return Smi::FromInt(0); |
| 14556 return *object; | 14556 return *object; |
| 14557 } | 14557 } |
| 14558 | 14558 |
| 14559 | 14559 |
| 14560 RUNTIME_FUNCTION(RuntimeHidden_GetFromCache) { | 14560 RUNTIME_FUNCTION(Runtime_GetFromCache) { |
| 14561 SealHandleScope shs(isolate); | 14561 SealHandleScope shs(isolate); |
| 14562 // This is only called from codegen, so checks might be more lax. | 14562 // This is only called from codegen, so checks might be more lax. |
| 14563 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); | 14563 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); |
| 14564 CONVERT_ARG_CHECKED(Object, key, 1); | 14564 CONVERT_ARG_CHECKED(Object, key, 1); |
| 14565 | 14565 |
| 14566 { | 14566 { |
| 14567 DisallowHeapAllocation no_alloc; | 14567 DisallowHeapAllocation no_alloc; |
| 14568 | 14568 |
| 14569 int finger_index = cache->finger_index(); | 14569 int finger_index = cache->finger_index(); |
| 14570 Object* o = cache->get(finger_index); | 14570 Object* o = cache->get(finger_index); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14673 | 14673 |
| 14674 #ifdef DEBUG | 14674 #ifdef DEBUG |
| 14675 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 14675 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
| 14676 // Exclude the code in release mode. | 14676 // Exclude the code in release mode. |
| 14677 RUNTIME_FUNCTION(Runtime_ListNatives) { | 14677 RUNTIME_FUNCTION(Runtime_ListNatives) { |
| 14678 HandleScope scope(isolate); | 14678 HandleScope scope(isolate); |
| 14679 ASSERT(args.length() == 0); | 14679 ASSERT(args.length() == 0); |
| 14680 #define COUNT_ENTRY(Name, argc, ressize) + 1 | 14680 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
| 14681 int entry_count = 0 | 14681 int entry_count = 0 |
| 14682 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) | 14682 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
| 14683 RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY) | |
| 14684 INLINE_FUNCTION_LIST(COUNT_ENTRY) | 14683 INLINE_FUNCTION_LIST(COUNT_ENTRY) |
| 14685 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); | 14684 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); |
| 14686 #undef COUNT_ENTRY | 14685 #undef COUNT_ENTRY |
| 14687 Factory* factory = isolate->factory(); | 14686 Factory* factory = isolate->factory(); |
| 14688 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14687 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
| 14689 int index = 0; | 14688 int index = 0; |
| 14690 bool inline_runtime_functions = false; | 14689 bool inline_runtime_functions = false; |
| 14691 #define ADD_ENTRY(Name, argc, ressize) \ | 14690 #define ADD_ENTRY(Name, argc, ressize) \ |
| 14692 { \ | 14691 { \ |
| 14693 HandleScope inner(isolate); \ | 14692 HandleScope inner(isolate); \ |
| 14694 Handle<String> name; \ | 14693 Handle<String> name; \ |
| 14695 /* Inline runtime functions have an underscore in front of the name. */ \ | 14694 /* Inline runtime functions have an underscore in front of the name. */ \ |
| 14696 if (inline_runtime_functions) { \ | 14695 if (inline_runtime_functions) { \ |
| 14697 name = factory->NewStringFromStaticAscii("_" #Name); \ | 14696 name = factory->NewStringFromStaticAscii("_" #Name); \ |
| 14698 } else { \ | 14697 } else { \ |
| 14699 name = factory->NewStringFromStaticAscii(#Name); \ | 14698 name = factory->NewStringFromStaticAscii(#Name); \ |
| 14700 } \ | 14699 } \ |
| 14701 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ | 14700 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ |
| 14702 pair_elements->set(0, *name); \ | 14701 pair_elements->set(0, *name); \ |
| 14703 pair_elements->set(1, Smi::FromInt(argc)); \ | 14702 pair_elements->set(1, Smi::FromInt(argc)); \ |
| 14704 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ | 14703 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ |
| 14705 elements->set(index++, *pair); \ | 14704 elements->set(index++, *pair); \ |
| 14706 } | 14705 } |
| 14707 inline_runtime_functions = false; | 14706 inline_runtime_functions = false; |
| 14708 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 14707 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| 14709 INLINE_OPTIMIZED_FUNCTION_LIST(ADD_ENTRY) | 14708 INLINE_OPTIMIZED_FUNCTION_LIST(ADD_ENTRY) |
| 14710 // Calling hidden runtime functions should just throw. | |
| 14711 RUNTIME_HIDDEN_FUNCTION_LIST(ADD_ENTRY) | |
| 14712 inline_runtime_functions = true; | 14709 inline_runtime_functions = true; |
| 14713 INLINE_FUNCTION_LIST(ADD_ENTRY) | 14710 INLINE_FUNCTION_LIST(ADD_ENTRY) |
| 14714 #undef ADD_ENTRY | 14711 #undef ADD_ENTRY |
| 14715 ASSERT_EQ(index, entry_count); | 14712 ASSERT_EQ(index, entry_count); |
| 14716 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 14713 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
| 14717 return *result; | 14714 return *result; |
| 14718 } | 14715 } |
| 14719 #endif | 14716 #endif |
| 14720 | 14717 |
| 14721 | 14718 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14983 !can_use_type_feedback)) { | 14980 !can_use_type_feedback)) { |
| 14984 // The arguments passed in caused a transition. This kind of complexity | 14981 // The arguments passed in caused a transition. This kind of complexity |
| 14985 // can't be dealt with in the inlined hydrogen array constructor case. | 14982 // can't be dealt with in the inlined hydrogen array constructor case. |
| 14986 // We must mark the allocationsite as un-inlinable. | 14983 // We must mark the allocationsite as un-inlinable. |
| 14987 site->SetDoNotInlineCall(); | 14984 site->SetDoNotInlineCall(); |
| 14988 } | 14985 } |
| 14989 return *array; | 14986 return *array; |
| 14990 } | 14987 } |
| 14991 | 14988 |
| 14992 | 14989 |
| 14993 RUNTIME_FUNCTION(RuntimeHidden_ArrayConstructor) { | 14990 RUNTIME_FUNCTION(Runtime_ArrayConstructor) { |
| 14994 HandleScope scope(isolate); | 14991 HandleScope scope(isolate); |
| 14995 // If we get 2 arguments then they are the stub parameters (constructor, type | 14992 // If we get 2 arguments then they are the stub parameters (constructor, type |
| 14996 // info). If we get 4, then the first one is a pointer to the arguments | 14993 // info). If we get 4, then the first one is a pointer to the arguments |
| 14997 // passed by the caller, and the last one is the length of the arguments | 14994 // passed by the caller, and the last one is the length of the arguments |
| 14998 // passed to the caller (redundant, but useful to check on the deoptimizer | 14995 // passed to the caller (redundant, but useful to check on the deoptimizer |
| 14999 // with an assert). | 14996 // with an assert). |
| 15000 Arguments empty_args(0, NULL); | 14997 Arguments empty_args(0, NULL); |
| 15001 bool no_caller_args = args.length() == 2; | 14998 bool no_caller_args = args.length() == 2; |
| 15002 ASSERT(no_caller_args || args.length() == 4); | 14999 ASSERT(no_caller_args || args.length() == 4); |
| 15003 int parameters_start = no_caller_args ? 0 : 1; | 15000 int parameters_start = no_caller_args ? 0 : 1; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 15020 ASSERT(!site->SitePointsToLiteral()); | 15017 ASSERT(!site->SitePointsToLiteral()); |
| 15021 } | 15018 } |
| 15022 | 15019 |
| 15023 return ArrayConstructorCommon(isolate, | 15020 return ArrayConstructorCommon(isolate, |
| 15024 constructor, | 15021 constructor, |
| 15025 site, | 15022 site, |
| 15026 caller_args); | 15023 caller_args); |
| 15027 } | 15024 } |
| 15028 | 15025 |
| 15029 | 15026 |
| 15030 RUNTIME_FUNCTION(RuntimeHidden_InternalArrayConstructor) { | 15027 RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) { |
| 15031 HandleScope scope(isolate); | 15028 HandleScope scope(isolate); |
| 15032 Arguments empty_args(0, NULL); | 15029 Arguments empty_args(0, NULL); |
| 15033 bool no_caller_args = args.length() == 1; | 15030 bool no_caller_args = args.length() == 1; |
| 15034 ASSERT(no_caller_args || args.length() == 3); | 15031 ASSERT(no_caller_args || args.length() == 3); |
| 15035 int parameters_start = no_caller_args ? 0 : 1; | 15032 int parameters_start = no_caller_args ? 0 : 1; |
| 15036 Arguments* caller_args = no_caller_args | 15033 Arguments* caller_args = no_caller_args |
| 15037 ? &empty_args | 15034 ? &empty_args |
| 15038 : reinterpret_cast<Arguments*>(args[0]); | 15035 : reinterpret_cast<Arguments*>(args[0]); |
| 15039 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 15036 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
| 15040 #ifdef DEBUG | 15037 #ifdef DEBUG |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 15057 | 15054 |
| 15058 | 15055 |
| 15059 // ---------------------------------------------------------------------------- | 15056 // ---------------------------------------------------------------------------- |
| 15060 // Implementation of Runtime | 15057 // Implementation of Runtime |
| 15061 | 15058 |
| 15062 #define F(name, number_of_args, result_size) \ | 15059 #define F(name, number_of_args, result_size) \ |
| 15063 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 15060 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
| 15064 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15061 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
| 15065 | 15062 |
| 15066 | 15063 |
| 15067 #define FH(name, number_of_args, result_size) \ | |
| 15068 { Runtime::kHidden##name, Runtime::RUNTIME_HIDDEN, NULL, \ | |
| 15069 FUNCTION_ADDR(RuntimeHidden_##name), number_of_args, result_size }, | |
| 15070 | |
| 15071 | |
| 15072 #define I(name, number_of_args, result_size) \ | 15064 #define I(name, number_of_args, result_size) \ |
| 15073 { Runtime::kInline##name, Runtime::INLINE, \ | 15065 { Runtime::kInline##name, Runtime::INLINE, \ |
| 15074 "_" #name, NULL, number_of_args, result_size }, | 15066 "_" #name, NULL, number_of_args, result_size }, |
| 15075 | 15067 |
| 15076 | 15068 |
| 15077 #define IO(name, number_of_args, result_size) \ | 15069 #define IO(name, number_of_args, result_size) \ |
| 15078 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \ | 15070 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \ |
| 15079 "_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15071 "_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
| 15080 | 15072 |
| 15081 | 15073 |
| 15082 static const Runtime::Function kIntrinsicFunctions[] = { | 15074 static const Runtime::Function kIntrinsicFunctions[] = { |
| 15083 RUNTIME_FUNCTION_LIST(F) | 15075 RUNTIME_FUNCTION_LIST(F) |
| 15084 INLINE_OPTIMIZED_FUNCTION_LIST(F) | 15076 INLINE_OPTIMIZED_FUNCTION_LIST(F) |
| 15085 RUNTIME_HIDDEN_FUNCTION_LIST(FH) | |
| 15086 INLINE_FUNCTION_LIST(I) | 15077 INLINE_FUNCTION_LIST(I) |
| 15087 INLINE_OPTIMIZED_FUNCTION_LIST(IO) | 15078 INLINE_OPTIMIZED_FUNCTION_LIST(IO) |
| 15088 }; | 15079 }; |
| 15089 | 15080 |
| 15090 #undef IO | 15081 #undef IO |
| 15091 #undef I | 15082 #undef I |
| 15092 #undef FH | 15083 #undef FH |
|
Michael Starzinger
2014/06/24 13:06:05
nit: Please also drop the "#undef FH" here.
danno
2014/06/24 16:22:48
Done.
| |
| 15093 #undef F | 15084 #undef F |
| 15094 | 15085 |
| 15095 | 15086 |
| 15096 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, | 15087 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, |
| 15097 Handle<NameDictionary> dict) { | 15088 Handle<NameDictionary> dict) { |
| 15098 ASSERT(dict->NumberOfElements() == 0); | 15089 ASSERT(dict->NumberOfElements() == 0); |
| 15099 HandleScope scope(isolate); | 15090 HandleScope scope(isolate); |
| 15100 for (int i = 0; i < kNumFunctions; ++i) { | 15091 for (int i = 0; i < kNumFunctions; ++i) { |
| 15101 const char* name = kIntrinsicFunctions[i].name; | 15092 const char* name = kIntrinsicFunctions[i].name; |
| 15102 if (name == NULL) continue; | 15093 if (name == NULL) continue; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 15121 } | 15112 } |
| 15122 return NULL; | 15113 return NULL; |
| 15123 } | 15114 } |
| 15124 | 15115 |
| 15125 | 15116 |
| 15126 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15117 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15127 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15118 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15128 } | 15119 } |
| 15129 | 15120 |
| 15130 } } // namespace v8::internal | 15121 } } // namespace v8::internal |
| OLD | NEW |