Commit Graph

910 Commits

Author SHA1 Message Date
Ilya Matveev 7bf9669f57 stdlib: Add clear and remove methods in AbstractMutableCollection 2017-04-18 12:48:07 +07:00
Ilya Matveev 321386d95e stdlib: Improve ArrayList.removeAll implementation.
This patch replaces ArrayList.removeAll implementation with a
faster one. It also adds the AbstractMutableCollection class
containing default implementations for addAll, removeAll and
retainAll methods and fixes tests to check if removeAll removes
all occurrences found or not.
2017-04-18 12:48:07 +07:00
Ilya Matveev 64f1cea134 tests: Do not rely on Kotlin JVM impl in sort tests
Some sort tests had an order of equal objects in a sorted list
hardcoded. It caused failures because an approach to placing
equal objects differs in Kotlin JVM and Kotlin Native sort
implementations. With this patch we check if all objects in a list
are sorted istead of checking an exact order of them.
2017-04-18 12:48:07 +07:00
Ilya Matveev 7dd27dd16d stdlib: Provide Collection.toArray() implementation
It also modifies the test for this method to make it to not rely on
Kotlin JVM implementation.
2017-04-18 12:48:07 +07:00
Konstantin Anisimov 0f24850f3c Descriptor return type must coincide with expression return type 2017-04-17 16:01:02 +07:00
Konstantin Anisimov 5920e0d8ba Do not create new descriptors for "call" instructions. Calls for functions declared in inlineBody will be substituted in second pass 2017-04-17 16:01:02 +07:00
Konstantin Anisimov 42955526bf Use original DeepCopyIrTree algorithm in visitCall 2017-04-17 16:01:02 +07:00
Vasily Levchenko 89ebbaeb6c DEBUGINFO: initial C bindings to debug info llvm
- support DICompileUnit
- support DIFIle
- support DISubroutine
- support DIBasicType
- support DILocation
- added gradle build
- debug info bindings are involved in kotlin build
- added binding to DIGetSubprogramLinkName
- added binding to LLVMBuilderGetCurrentFunction
- added reset location
- simple demo added (buildable with gradle)
  produces folowing output:
    Following pseudo code in sources.
     0:123456789012345678901
     1: fun main():Int {
     2:   {foo()}()
     3:   return 0
     4: }
     5  fun foo() {}

    0:b-backend-dwarf:minamoto@unit-703(0)# ./demo
    ; ModuleID = 'test'
    source_filename = "test"

    define i32 @foo(i32) !dbg !3 {
    entry:
      ret i32 %0, !dbg !7
    }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "1.kt", directory: "src")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "foo", linkageName: "foo:link", scope: null, file: !1, line: 66, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !5)
    !5 = !{!6}
    !6 = !DIBasicType(name: "int", size: 32, align: 4)
    !7 = !DILocation(line: 42, column: 15, scope: !3)
- demo sharing debug information between several bitcode artifacts
    0:b-backend-dwarf:minamoto@unit-703(0)# llvmDebugInfoC/build/exe/demogenerated/demogenerated
    ; ModuleID = 'test'
    source_filename = "test"

    define void @foo() !dbg !3 {
    entry:
      ret void, !dbg !5
    }

    define void @"main$caller$foo"() !dbg !6 {
    entry:
      call void @foo(), !dbg !7
      ret void
    }

    define void @main() !dbg !8 {
    entry:
      call void @"main$caller$foo"(), !dbg !9
      ret void, !dbg !10
    }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "<stdin>", directory: "")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 5, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !2)
    !5 = !DILocation(line: 5, column: 14, scope: !3)
    !6 = distinct !DISubprogram(name: "main$caller$foo", linkageName: "main$caller$foo", scope: null, file: !1, line: 2, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !7 = !DILocation(line: 5, column: 2, scope: !6)
    !8 = distinct !DISubprogram(name: "main", linkageName: "main", scope: null, file: !1, line: 1, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !9 = !DILocation(line: 2, column: 12, scope: !8)
    !10 = !DILocation(line: 3, column: 4, scope: !8)
- local variables support
- demo for local variable suppor (TBD some out put here).
    ; ModuleID = 'test'
    source_filename = "test"

    define i32 @main() !dbg !3 {
    entry:
    %0 = alloca i32
    call void @llvm.dbg.declare(metadata i32* %0, metadata !5, metadata !7), !dbg !8
    store i32 42, i32* %0, !dbg !8
    %1 = load i32, i32* %0, !dbg !8
    ret i32 %1, !dbg !8
    }

    ; Function Attrs: nounwind readnone
    declare void @llvm.dbg.declare(metadata, metadata, metadata) #0

    attributes #0 = { nounwind readnone }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "<stdin>", directory: "")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "main", linkageName: "main", scope: null, file: !1, line: 1, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !2)
    !5 = !DILocalVariable(name: "a", scope: !3, file: !1, line: 2, type: !6)
    !6 = !DIBasicType(name: "int", size: 32, align: 4)
    !7 = !DIExpression()
    !8 = !DILocation(line: 2, column: 1, scope: !3)
2017-04-14 11:39:51 +03:00
Konstantin Anisimov 6e7eff4c03 No visitor with context needed to lookup for descriptors. Containing declaration must already be in descriptorSubstituteMap or to be left unchanged 2017-04-13 19:38:34 +07:00
Konstantin Anisimov 00a3dfc4b7 Get rid of warnings in inliner code
Fix problem with "Duplicate IR node" warning
2017-04-13 19:38:34 +07:00
Konstantin Anisimov 9830454b58 Associate copyIrElement with inlining target context 2017-04-13 19:38:34 +07:00
Konstantin Anisimov 90a43a4c62 Code refactoring 2017-04-13 19:38:34 +07:00
Konstantin Anisimov 1f1de99878 Move call site descriptor substitutor to main algotithm 2017-04-13 19:38:34 +07:00
Ilya Matveev ec64fd0477 stdlib: Make toIndex exclusive in sortArrayWith method
This patch makes toIndex parameter exclusive in sortArrayWith method
in order to make this method corresponding to the other ones (e.g.
copyOfRange, Array.sortWith extension etc).
It also improves the external sortBy test in order to use it with
different sort algorithms.
2017-04-13 18:27:08 +07:00
Ilya Matveev bd27d68906 stdlib: Fix contentDeepToString 2017-04-13 18:27:08 +07:00
Vasily Levchenko eadcd98740 kotlin-compiler: 1.1-20170412.175827-457 2017-04-13 12:21:04 +03:00
Konstantin Anisimov 78c043f15f All FunctionDescriptors on call sites must be copied 2017-04-11 19:12:00 +07:00
Svyatoslav Scherbina 2a3450047c Add interop test for returning struct by value 2017-04-10 17:28:25 +03:00
Svyatoslav Scherbina 716efe7310 Workaround incomplete inline for interop's readValue 2017-04-10 17:28:25 +03:00
Nikolay Igotti 2227415448 Remove remnants of concurrent memory model (#467) 2017-04-10 16:49:46 +03:00
Nikolay Igotti 4f13da844f Fix iphone build (#465) 2017-04-10 16:14:53 +03:00
Vasily Levchenko b54ff99fc7 --print_locations: don't print null, please name instead.
(cherry picked from commit 55a96696179dc8854d25f9c4ab429abab604e200)
2017-04-10 16:14:29 +03:00
Igor Chevdar f389afee16 Added compiler arg --print_ir_with_descriptors
Sometimes it would be useful to see IR with all corresponding
descriptors - now it is possible.
2017-04-10 14:45:55 +03:00
Konstantin Anisimov 8fc1577fe5 Reduce obsolete code
Wrote comments
2017-04-10 18:45:28 +07:00
Konstantin Anisimov 6568efbac8 Move TypeSybstitutor creation in InlineFunction
Property "currentFile" expected to return IrFile
Print warning if deserializer failed to bring function declaration
2017-04-10 18:45:28 +07:00
Konstantin Anisimov 8235c8b2be New scheme for copy descriptors names 2017-04-10 18:45:28 +07:00
Konstantin Anisimov 34e49ffb82 Unify inlining procedure for "function" and "lambda" 2017-04-10 18:45:28 +07:00
Konstantin Anisimov 9f4e1a92d8 Unify inlining procedure for "function" and "lambda" 2017-04-10 18:45:28 +07:00
Nikolay Igotti 100e4df05d Concurrency prototype (#453)
* Concurrent executors

* Review feedback
2017-04-07 15:16:04 +03:00
Alexander Gorshenev 49674d2b1b Some mangling disambiguation tests. 2017-04-07 13:47:52 +03:00
Alexander Gorshenev f91bc457db Disambiguate upper bounds in the mangling. 2017-04-07 13:47:52 +03:00
Ilya Matveev a69def4254 tests: Generate test tasks for stdlib tests
This patch updates the test execution harness to work with the
new stdlib tests. It allows one to execute stdlib tests as
a part of external testing (./gradlew run_external) or separately
(./gradlew run_external -Pprefix=external_stdlib).
2017-04-07 17:21:11 +07:00
Ilya Matveev 85827b4880 tests: Copy stdlib tests from Kotlin/JVM
This patch copies Kotlin/JVM stdlib tests (libraries/stdlib/test)
excepting ones with explicit java dependencies. It also transforms
the tests to use them as box-tests.
2017-04-07 17:21:11 +07:00
Igor Chevdar 8690b00790 Refactoring 2017-04-07 08:01:16 +07:00
Igor Chevdar db50381bc9 Inline: set correct containing declaration + some fixes
1. Containing declaration can be computed as parent from the IR.

2. Sometimes we need to substitute FunctionDescriptor which is defined
inside an inline function call but nevertheless leaks to the outside:

public inline fun <T, R> T.myLet(f: (T) -> R): R = f(this)

interface foo {
    fun bar(): String
}

fun box(): String {
    val baz = "OK".myLet {
        object : foo {
            override fun bar() = it
        }
    }
    return baz.bar()
}
2017-04-07 08:01:16 +07:00
Konstantin Anisimov 3c2b5a9762 Fixed "interop0" failure 2017-04-06 16:25:11 +03:00
Konstantin Anisimov 53bc4b1872 Eliminated special treatment for lambda parameter -> argument map building
Fix for ClassDescriptors substitution
2017-04-06 16:25:11 +03:00
Konstantin Anisimov 82917eafbd Move copying descriptors and types in InlineCopyIr 2017-04-06 16:25:11 +03:00
Konstantin Anisimov 7ec89caf27 Avoid evaluation ANONIMOUS_FUNCTION as argument 2017-04-06 16:25:11 +03:00
SvyatoslavScherbina 058bb728df kotlin-compiler: 1.1-20170403.193854-443 (#452) 2017-04-05 20:48:58 +03:00
Igor Chevdar f5e3519d3a Inline: implemented properties copying 2017-04-05 14:30:03 +03:00
Igor Chevdar e9b207595a Inline: correct set of super class for ClassDescriptor 2017-04-05 14:30:03 +03:00
Vasily Levchenko 461b977cae TEST: build slack teamcity properties for testing:
- NEVER commit if konan-reporter-token contains real token.
2017-04-05 14:27:16 +03:00
Alexander Gorshenev 3f625ce1b2 More primitive types for constants. 2017-04-05 12:09:43 +03:00
Alexander Gorshenev 429bc31b82 No serialization for "external public inline" functions. 2017-04-05 12:09:43 +03:00
Konstantin Anisimov a70d5293b3 Typo fixed 2017-04-04 18:02:01 +07:00
Konstantin Anisimov 5f9f0e55d0 Optimize import 2017-04-04 18:02:01 +07:00
Konstantin Anisimov c7de1d452f Move type operations in DeepCopyIrTreeWithDescriptors 2017-04-04 18:02:01 +07:00
Konstantin Anisimov 276c14a896 Minor refactoring 2017-04-04 18:02:01 +07:00
Konstantin Anisimov 90b910fd53 Igor's fixes 2017-04-04 18:02:01 +07:00