OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/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/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 case CompileTimeValue::ARRAY_LITERAL: | 229 case CompileTimeValue::ARRAY_LITERAL: |
230 return Runtime::CreateArrayLiteralBoilerplate(isolate, literals, | 230 return Runtime::CreateArrayLiteralBoilerplate(isolate, literals, |
231 elements, is_strong); | 231 elements, is_strong); |
232 default: | 232 default: |
233 UNREACHABLE(); | 233 UNREACHABLE(); |
234 return MaybeHandle<Object>(); | 234 return MaybeHandle<Object>(); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 | 238 |
| 239 RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { |
| 240 HandleScope scope(isolate); |
| 241 DCHECK_EQ(4, args.length()); |
| 242 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
| 243 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 244 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
| 245 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
| 246 |
| 247 // Check if boilerplate exists. If not, create it first. |
| 248 Handle<Object> boilerplate(closure->literals()->literal(index), isolate); |
| 249 if (boilerplate->IsUndefined()) { |
| 250 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, boilerplate, |
| 251 JSRegExp::New(pattern, flags)); |
| 252 closure->literals()->set_literal(index, *boilerplate); |
| 253 } |
| 254 return *JSRegExp::Copy(Handle<JSRegExp>::cast(boilerplate)); |
| 255 } |
| 256 |
| 257 |
239 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { | 258 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { |
240 HandleScope scope(isolate); | 259 HandleScope scope(isolate); |
241 DCHECK_EQ(4, args.length()); | 260 DCHECK_EQ(4, args.length()); |
242 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); | 261 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
243 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 262 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
244 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 263 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
245 CONVERT_SMI_ARG_CHECKED(flags, 3); | 264 CONVERT_SMI_ARG_CHECKED(flags, 3); |
246 Handle<LiteralsArray> literals(closure->literals(), isolate); | 265 Handle<LiteralsArray> literals(closure->literals(), isolate); |
247 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 266 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
248 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 267 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); | 451 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); |
433 } | 452 } |
434 } | 453 } |
435 FixedArray* object_array = FixedArray::cast(object->elements()); | 454 FixedArray* object_array = FixedArray::cast(object->elements()); |
436 object_array->set(store_index, *value); | 455 object_array->set(store_index, *value); |
437 } | 456 } |
438 return *object; | 457 return *object; |
439 } | 458 } |
440 } // namespace internal | 459 } // namespace internal |
441 } // namespace v8 | 460 } // namespace v8 |
OLD | NEW |