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

Side by Side Diff: src/runtime.cc

Issue 143633007: A64: Synchronize with r18764. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/rewriter.cc ('k') | src/scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // slow properties mode for now. We don't go in the map cache because 252 // slow properties mode for now. We don't go in the map cache because
253 // maps with constant functions can't be shared if the functions are 253 // maps with constant functions can't be shared if the functions are
254 // not the same (which is the common case). 254 // not the same (which is the common case).
255 bool is_result_from_cache = false; 255 bool is_result_from_cache = false;
256 Handle<Map> map = has_function_literal 256 Handle<Map> map = has_function_literal
257 ? Handle<Map>(context->object_function()->initial_map()) 257 ? Handle<Map>(context->object_function()->initial_map())
258 : ComputeObjectLiteralMap(context, 258 : ComputeObjectLiteralMap(context,
259 constant_properties, 259 constant_properties,
260 &is_result_from_cache); 260 &is_result_from_cache);
261 261
262 PretenureFlag pretenure_flag =
263 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
264
262 Handle<JSObject> boilerplate = 265 Handle<JSObject> boilerplate =
263 isolate->factory()->NewJSObjectFromMap( 266 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag);
264 map, isolate->heap()->GetPretenureMode());
265 267
266 // Normalize the elements of the boilerplate to save space if needed. 268 // Normalize the elements of the boilerplate to save space if needed.
267 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); 269 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate);
268 270
269 // Add the constant properties to the boilerplate. 271 // Add the constant properties to the boilerplate.
270 int length = constant_properties->length(); 272 int length = constant_properties->length();
271 bool should_transform = 273 bool should_transform =
272 !is_result_from_cache && boilerplate->HasFastProperties(); 274 !is_result_from_cache && boilerplate->HasFastProperties();
273 if (should_transform || has_function_literal) { 275 if (should_transform || has_function_literal) {
274 // Normalize the properties of object to avoid n^2 behavior 276 // Normalize the properties of object to avoid n^2 behavior
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 362
361 363
362 Handle<Object> Runtime::CreateArrayLiteralBoilerplate( 364 Handle<Object> Runtime::CreateArrayLiteralBoilerplate(
363 Isolate* isolate, 365 Isolate* isolate,
364 Handle<FixedArray> literals, 366 Handle<FixedArray> literals,
365 Handle<FixedArray> elements) { 367 Handle<FixedArray> elements) {
366 // Create the JSArray. 368 // Create the JSArray.
367 Handle<JSFunction> constructor( 369 Handle<JSFunction> constructor(
368 JSFunction::NativeContextFromLiterals(*literals)->array_function()); 370 JSFunction::NativeContextFromLiterals(*literals)->array_function());
369 371
372 PretenureFlag pretenure_flag =
373 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
374
370 Handle<JSArray> object = Handle<JSArray>::cast( 375 Handle<JSArray> object = Handle<JSArray>::cast(
371 isolate->factory()->NewJSObject( 376 isolate->factory()->NewJSObject(constructor, pretenure_flag));
372 constructor, isolate->heap()->GetPretenureMode()));
373 377
374 ElementsKind constant_elements_kind = 378 ElementsKind constant_elements_kind =
375 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); 379 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value());
376 Handle<FixedArrayBase> constant_elements_values( 380 Handle<FixedArrayBase> constant_elements_values(
377 FixedArrayBase::cast(elements->get(1))); 381 FixedArrayBase::cast(elements->get(1)));
378 382
379 ASSERT(IsFastElementsKind(constant_elements_kind)); 383 ASSERT(IsFastElementsKind(constant_elements_kind));
380 Context* native_context = isolate->context()->native_context(); 384 Context* native_context = isolate->context()->native_context();
381 Object* maybe_maps_array = native_context->js_array_maps(); 385 Object* maybe_maps_array = native_context->js_array_maps();
382 ASSERT(!maybe_maps_array->IsUndefined()); 386 ASSERT(!maybe_maps_array->IsUndefined());
(...skipping 4828 matching lines...) Expand 10 before | Expand all | Expand 10 after
5211 // JavaScript. 5215 // JavaScript.
5212 // In the case of a String object we just need to redirect the assignment to 5216 // In the case of a String object we just need to redirect the assignment to
5213 // the underlying string if the index is in range. Since the underlying 5217 // the underlying string if the index is in range. Since the underlying
5214 // string does nothing with the assignment then we can ignore such 5218 // string does nothing with the assignment then we can ignore such
5215 // assignments. 5219 // assignments.
5216 if (js_object->IsStringObjectWithCharacterAt(index)) { 5220 if (js_object->IsStringObjectWithCharacterAt(index)) {
5217 return value; 5221 return value;
5218 } 5222 }
5219 5223
5220 js_object->ValidateElements(); 5224 js_object->ValidateElements();
5221 if (js_object->HasExternalArrayElements()) { 5225 if (js_object->HasExternalArrayElements() ||
5226 js_object->HasFixedTypedArrayElements()) {
5222 if (!value->IsNumber() && !value->IsUndefined()) { 5227 if (!value->IsNumber() && !value->IsUndefined()) {
5223 bool has_exception; 5228 bool has_exception;
5224 Handle<Object> number = 5229 Handle<Object> number =
5225 Execution::ToNumber(isolate, value, &has_exception); 5230 Execution::ToNumber(isolate, value, &has_exception);
5226 if (has_exception) return Handle<Object>(); // exception 5231 if (has_exception) return Handle<Object>(); // exception
5227 value = number; 5232 value = number;
5228 } 5233 }
5229 } 5234 }
5230 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, 5235 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr,
5231 strict_mode, 5236 strict_mode,
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
6801 } 6806 }
6802 6807
6803 6808
6804 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { 6809 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) {
6805 SealHandleScope shs(isolate); 6810 SealHandleScope shs(isolate);
6806 ASSERT(args.length() == 1); 6811 ASSERT(args.length() == 1);
6807 6812
6808 Object* number = args[0]; 6813 Object* number = args[0];
6809 RUNTIME_ASSERT(number->IsNumber()); 6814 RUNTIME_ASSERT(number->IsNumber());
6810 6815
6811 return isolate->heap()->NumberToString( 6816 return isolate->heap()->NumberToString(number, false);
6812 number, false, isolate->heap()->GetPretenureMode());
6813 } 6817 }
6814 6818
6815 6819
6816 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { 6820 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) {
6817 SealHandleScope shs(isolate); 6821 SealHandleScope shs(isolate);
6818 ASSERT(args.length() == 1); 6822 ASSERT(args.length() == 1);
6819 6823
6820 CONVERT_DOUBLE_ARG_CHECKED(number, 0); 6824 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
6821 6825
6822 // We do not include 0 so that we don't have to treat +0 / -0 cases. 6826 // We do not include 0 so that we don't have to treat +0 / -0 cases.
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
8858 8862
8859 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8863 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8860 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); 8864 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1);
8861 Context* result; 8865 Context* result;
8862 MaybeObject* maybe_result = 8866 MaybeObject* maybe_result =
8863 isolate->heap()->AllocateGlobalContext(function, scope_info); 8867 isolate->heap()->AllocateGlobalContext(function, scope_info);
8864 if (!maybe_result->To(&result)) return maybe_result; 8868 if (!maybe_result->To(&result)) return maybe_result;
8865 8869
8866 ASSERT(function->context() == isolate->context()); 8870 ASSERT(function->context() == isolate->context());
8867 ASSERT(function->context()->global_object() == result->global_object()); 8871 ASSERT(function->context()->global_object() == result->global_object());
8868 isolate->set_context(result);
8869 result->global_object()->set_global_context(result); 8872 result->global_object()->set_global_context(result);
8870 8873
8871 return result; // non-failure 8874 return result; // non-failure
8872 } 8875 }
8873 8876
8874 8877
8875 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { 8878 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) {
8876 SealHandleScope shs(isolate); 8879 SealHandleScope shs(isolate);
8877 ASSERT(args.length() == 1); 8880 ASSERT(args.length() == 1);
8878 8881
8879 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8882 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8880 int length = function->shared()->scope_info()->ContextLength(); 8883 int length = function->shared()->scope_info()->ContextLength();
8881 Context* result; 8884 return isolate->heap()->AllocateFunctionContext(length, function);
8882 MaybeObject* maybe_result =
8883 isolate->heap()->AllocateFunctionContext(length, function);
8884 if (!maybe_result->To(&result)) return maybe_result;
8885
8886 isolate->set_context(result);
8887
8888 return result; // non-failure
8889 } 8885 }
8890 8886
8891 8887
8892 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { 8888 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) {
8893 SealHandleScope shs(isolate); 8889 SealHandleScope shs(isolate);
8894 ASSERT(args.length() == 2); 8890 ASSERT(args.length() == 2);
8895 JSReceiver* extension_object; 8891 JSReceiver* extension_object;
8896 if (args[0]->IsJSReceiver()) { 8892 if (args[0]->IsJSReceiver()) {
8897 extension_object = JSReceiver::cast(args[0]); 8893 extension_object = JSReceiver::cast(args[0]);
8898 } else { 8894 } else {
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
10000 case NON_STRICT_ARGUMENTS_ELEMENTS: 9996 case NON_STRICT_ARGUMENTS_ELEMENTS:
10001 case EXTERNAL_BYTE_ELEMENTS: 9997 case EXTERNAL_BYTE_ELEMENTS:
10002 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 9998 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
10003 case EXTERNAL_SHORT_ELEMENTS: 9999 case EXTERNAL_SHORT_ELEMENTS:
10004 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 10000 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
10005 case EXTERNAL_INT_ELEMENTS: 10001 case EXTERNAL_INT_ELEMENTS:
10006 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 10002 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
10007 case EXTERNAL_FLOAT_ELEMENTS: 10003 case EXTERNAL_FLOAT_ELEMENTS:
10008 case EXTERNAL_DOUBLE_ELEMENTS: 10004 case EXTERNAL_DOUBLE_ELEMENTS:
10009 case EXTERNAL_PIXEL_ELEMENTS: 10005 case EXTERNAL_PIXEL_ELEMENTS:
10006 case UINT8_ELEMENTS:
10007 case INT8_ELEMENTS:
10008 case UINT16_ELEMENTS:
10009 case INT16_ELEMENTS:
10010 case UINT32_ELEMENTS:
10011 case INT32_ELEMENTS:
10012 case FLOAT32_ELEMENTS:
10013 case FLOAT64_ELEMENTS:
10014 case UINT8_CLAMPED_ELEMENTS:
10010 // External arrays are always dense. 10015 // External arrays are always dense.
10011 return length; 10016 return length;
10012 } 10017 }
10013 // As an estimate, we assume that the prototype doesn't contain any 10018 // As an estimate, we assume that the prototype doesn't contain any
10014 // inherited elements. 10019 // inherited elements.
10015 return element_count; 10020 return element_count;
10016 } 10021 }
10017 10022
10018 10023
10019 10024
(...skipping 4742 matching lines...) Expand 10 before | Expand all | Expand 10 after
14762 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1); 14767 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1);
14763 #ifdef DEBUG 14768 #ifdef DEBUG
14764 if (!no_caller_args) { 14769 if (!no_caller_args) {
14765 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2); 14770 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2);
14766 ASSERT(arg_count == caller_args->length()); 14771 ASSERT(arg_count == caller_args->length());
14767 } 14772 }
14768 #endif 14773 #endif
14769 14774
14770 Handle<AllocationSite> site; 14775 Handle<AllocationSite> site;
14771 if (!type_info.is_null() && 14776 if (!type_info.is_null() &&
14772 *type_info != isolate->heap()->undefined_value() && 14777 *type_info != isolate->heap()->undefined_value()) {
14773 Cell::cast(*type_info)->value()->IsAllocationSite()) { 14778 site = Handle<AllocationSite>::cast(type_info);
14774 site = Handle<AllocationSite>(
14775 AllocationSite::cast(Cell::cast(*type_info)->value()), isolate);
14776 ASSERT(!site->SitePointsToLiteral()); 14779 ASSERT(!site->SitePointsToLiteral());
14777 } 14780 }
14778 14781
14779 return ArrayConstructorCommon(isolate, 14782 return ArrayConstructorCommon(isolate,
14780 constructor, 14783 constructor,
14781 site, 14784 site,
14782 caller_args); 14785 caller_args);
14783 } 14786 }
14784 14787
14785 14788
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
14888 // Handle last resort GC and make sure to allow future allocations 14891 // Handle last resort GC and make sure to allow future allocations
14889 // to grow the heap without causing GCs (if possible). 14892 // to grow the heap without causing GCs (if possible).
14890 isolate->counters()->gc_last_resort_from_js()->Increment(); 14893 isolate->counters()->gc_last_resort_from_js()->Increment();
14891 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14894 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14892 "Runtime::PerformGC"); 14895 "Runtime::PerformGC");
14893 } 14896 }
14894 } 14897 }
14895 14898
14896 14899
14897 } } // namespace v8::internal 14900 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/rewriter.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698