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

Side by Side Diff: src/runtime/runtime-literals.cc

Issue 952303002: Remove NativeContext from Literal array, since we always create the literals in the native context … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-regexp.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 24 matching lines...) Expand all
35 35
36 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( 36 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
37 Isolate* isolate, Handle<FixedArray> literals, 37 Isolate* isolate, Handle<FixedArray> literals,
38 Handle<FixedArray> constant_properties); 38 Handle<FixedArray> constant_properties);
39 39
40 40
41 MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( 41 MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
42 Isolate* isolate, Handle<FixedArray> literals, 42 Isolate* isolate, Handle<FixedArray> literals,
43 Handle<FixedArray> constant_properties, bool should_have_fast_elements, 43 Handle<FixedArray> constant_properties, bool should_have_fast_elements,
44 bool has_function_literal) { 44 bool has_function_literal) {
45 // Get the native context from the literals array. This is the 45 Handle<Context> context = isolate->native_context();
46 // context in which the function was created and we use the object
47 // function from this context to create the object literal. We do
48 // not use the object function from the current native context
49 // because this might be the object function from another context
50 // which we should not have access to.
51 Handle<Context> context =
52 Handle<Context>(JSFunction::NativeContextFromLiterals(*literals));
53 46
54 // In case we have function literals, we want the object to be in 47 // In case we have function literals, we want the object to be in
55 // slow properties mode for now. We don't go in the map cache because 48 // slow properties mode for now. We don't go in the map cache because
56 // maps with constant functions can't be shared if the functions are 49 // maps with constant functions can't be shared if the functions are
57 // not the same (which is the common case). 50 // not the same (which is the common case).
58 bool is_result_from_cache = false; 51 bool is_result_from_cache = false;
59 Handle<Map> map = has_function_literal 52 Handle<Map> map = has_function_literal
60 ? Handle<Map>(context->object_function()->initial_map()) 53 ? Handle<Map>(context->object_function()->initial_map())
61 : ComputeObjectLiteralMap(context, constant_properties, 54 : ComputeObjectLiteralMap(context, constant_properties,
62 &is_result_from_cache); 55 &is_result_from_cache);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 "FastLiteral"); 132 "FastLiteral");
140 } 133 }
141 return boilerplate; 134 return boilerplate;
142 } 135 }
143 136
144 137
145 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( 138 MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
146 Isolate* isolate, Handle<FixedArray> literals, 139 Isolate* isolate, Handle<FixedArray> literals,
147 Handle<FixedArray> elements) { 140 Handle<FixedArray> elements) {
148 // Create the JSArray. 141 // Create the JSArray.
149 Handle<JSFunction> constructor( 142 Handle<JSFunction> constructor = isolate->array_function();
150 JSFunction::NativeContextFromLiterals(*literals)->array_function());
151 143
152 PretenureFlag pretenure_flag = 144 PretenureFlag pretenure_flag =
153 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; 145 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
154 146
155 Handle<JSArray> object = Handle<JSArray>::cast( 147 Handle<JSArray> object = Handle<JSArray>::cast(
156 isolate->factory()->NewJSObject(constructor, pretenure_flag)); 148 isolate->factory()->NewJSObject(constructor, pretenure_flag));
157 149
158 ElementsKind constant_elements_kind = 150 ElementsKind constant_elements_kind =
159 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); 151 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value());
160 Handle<FixedArrayBase> constant_elements_values( 152 Handle<FixedArrayBase> constant_elements_values(
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); 418 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind);
427 } 419 }
428 } 420 }
429 FixedArray* object_array = FixedArray::cast(object->elements()); 421 FixedArray* object_array = FixedArray::cast(object->elements());
430 object_array->set(store_index, *value); 422 object_array->set(store_index, *value);
431 } 423 }
432 return *object; 424 return *object;
433 } 425 }
434 } 426 }
435 } // namespace v8::internal 427 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698